This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SocketServer: server_address is... a socket
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: orsenthil, progval
Priority: normal Keywords:

Created on 2011-02-05 16:57 by progval, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg127999 - (view) Author: progval (progval) Date: 2011-02-05 16:57
Hello,

I have issues with a script I'm programming (TypeError at every client connection), so I edited BaseServer's __init__():
    def __init__(self, server_address, RequestHandlerClass):
        """Constructor.  May be extended, do not override."""
        if isinstance(server_address, socket._socketobject):
            raise Exception()
        self.server_address = server_address
        self.RequestHandlerClass = RequestHandlerClass
        self.__is_shut_down = threading.Event()
        self.__shutdown_request = False
And it raises sometimes this traceback:
Exception happened during processing of request from ('127.0.0.1', 32810)
Traceback (most recent call last):
  File "/usr/lib/python2.6/SocketServer.py", line 285, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.6/SocketServer.py", line 311, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.6/SocketServer.py", line 324, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.6/SocketServer.py", line 400, in __init__
    BaseServer.__init__(self, server_address, RequestHandlerClass)
  File "/usr/lib/python2.6/SocketServer.py", line 198, in __init__
    raise Exception()

Best regards,
ProgVal
msg128000 - (view) Author: progval (progval) Date: 2011-02-05 16:59
The problem happens on Python 2.7 too.

Additionaly, here is the traceback, if I don't edit the library:
Exception happened during processing of request from ('127.0.0.1', 50378)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 408, in __init__
    self.server_bind()
  File "/usr/lib/python2.7/SocketServer.py", line 419, in server_bind
    self.socket.bind(self.server_address)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
TypeError: getsockaddrarg: AF_INET address must be tuple, not _socketobject
msg128002 - (view) Author: progval (progval) Date: 2011-02-05 17:12
This seems odd to me: this line:
        self.RequestHandlerClass(request, client_address, self)
calls TCPServer's constructor:
    def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
msg128003 - (view) Author: progval (progval) Date: 2011-02-05 17:14
Oooooh, excuse me, it's because of my code!

class MyRequestHandler(SocketServer.TCPServer):
msg128004 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2011-02-05 17:15
Unable to determine the bug here. If you have questions with using python, please ask python-list@python.org
History
Date User Action Args
2022-04-11 14:57:12adminsetgithub: 55339
2011-02-05 17:15:45orsenthilsetstatus: open -> closed

nosy: + orsenthil
messages: + msg128004

type: behavior
stage: resolved
2011-02-05 17:14:14progvalsetresolution: not a bug
messages: + msg128003
2011-02-05 17:12:21progvalsetmessages: + msg128002
2011-02-05 16:59:44progvalsetmessages: + msg128000
versions: + Python 2.7
2011-02-05 16:57:24progvalcreate