classification
Title: SocketServer call shutdown in the wrong way
Type: behavior Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Erik.Günther, asvetlov, orsenthil, r.david.murray
Priority: normal Keywords:

Created on 2012-11-08 12:33 by Erik.Günther, last changed 2014-08-12 00:08 by r.david.murray. This issue is now closed.

Messages (6)
msg175152 - (view) Author: Erik Günther (Erik.Günther) Date: 2012-11-08 12:33
I have a small development WSGI-server using PythonPaste and when shutting it down I somtimes get the following error on one or two threads:


-----------------------8<-----------------------------------

Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/SocketServer.py", line 586, in process_request_thread
    self.shutdown_request(request)
  File "/usr/lib/python2.7/SocketServer.py", line 459, in shutdown_request
    request.shutdown(socket.SHUT_WR)
TypeError: shutdown() takes exactly 0 arguments (1 given)

--------------------->8-------------------------------------


/usr/lib/python2.7/SocketServer.py: ------------8<-----------

    def shutdown_request(self, request):
        """Called to shutdown and close an individual request."""
        try:
            #explicitly shutdown.  socket.close() merely releases
            #the socket and waits for GC to perform the actual close.
            request.shutdown(socket.SHUT_WR)
        except socket.error:
            pass #some platforms may raise ENOTCONN here
        self.close_request(request)

----------------->8------------------------------------------


So I recon its a bug...
msg175153 - (view) Author: Erik Günther (Erik.Günther) Date: 2012-11-08 12:47
Sorry forgot to tell in what versions..


Its in Ubuntu 12.04-1 Python version 2.7.3

Ubuntu package version: 2.7.3-0ubuntu3.1
msg176821 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-12-03 00:18
request should be socket.socket instance which definitely has shutdown method accepting socket.SHUT_WR.
I guest the problem not in stdlib but in your code or maybe in the Paste (I'm not familiar with it, sorry).
msg178544 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-12-30 00:08
Move to pending until additional info will be provided.
Required short test to reproduce the problem.
msg178717 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2012-12-31 22:38
Looks an invalid bug to me as well. request is a socket.socket object and has shutdown method taking a single argument. 
The error pasted in the report leads me to believe if the shutdown_request call is not thread-safe and it is ending up called shutdown method in the module instead of the proper shutdown method of the request object.
msg225212 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-08-12 00:08
Given the lack of additional info from the OP, I'm closing this.
History
Date User Action Args
2014-08-12 00:08:44r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg225212

resolution: not a bug
stage: test needed -> resolved
2012-12-31 22:38:12orsenthilsetstatus: pending -> open
nosy: + orsenthil
messages: + msg178717

2012-12-30 00:08:34asvetlovsetstatus: open -> pending

messages: + msg178544
2012-12-03 00:19:08asvetlovsetstage: needs patch -> test needed
2012-12-03 00:18:42asvetlovsetmessages: + msg176821
2012-11-15 19:42:44asvetlovsetstage: needs patch
2012-11-15 15:52:19asvetlovsetnosy: + asvetlov
2012-11-08 12:47:34Erik.Günthersetmessages: + msg175153
2012-11-08 12:34:07Erik.Günthersettype: crash -> behavior
2012-11-08 12:33:10Erik.Günthercreate