[Python-Dev] 2.4 asyncore headache

Tim Peters tim.peters at gmail.com
Fri Aug 13 21:58:28 CEST 2004


asyncore gives me a headache.  Windows sockets give me a headache. 
Zope's ZEO gives me a headache.  The ZEO test suite gives me
nightmares.

With that encouraging background, this ZEO test in ZODB 3.3 fails
every time when run on Windows under Python 2.4, but never under
Python 2.3.4:

checkReconnection
(ZEO.tests.testConnection.MappingStorageConnectionTests) ... Traceback
(most recent call last):
  File "C:\Code\ZODB3.3\build\lib.win32-2.4\ZEO\tests\zeoserver.py",
line 217, in ?
    main()
  File "C:\Code\ZODB3.3\build\lib.win32-2.4\ZEO\tests\zeoserver.py",
line 194, in main
    auth_realm=zo.auth_realm)
  File "C:\Code\ZODB3.3\build\lib.win32-2.4\ZEO\StorageServer.py",
line 738, in __init__
    factory=self.new_connection)
  File "C:\Code\ZODB3.3\build\lib.win32-2.4\ZEO\zrpc\server.py", line
34, in __init__
    self._open_socket()
  File "C:\Code\ZODB3.3\build\lib.win32-2.4\ZEO\zrpc\server.py", line
43, in _open_socket
    self.bind(self.addr)
  File "C:\Code\python\lib\asyncore.py", line 304, in bind
    return self.socket.bind(addr)
  File "<string>", line 1, in bind
socket.error: (10048, 'Address already in use')

unittest doesn't notice that failure, but the test hangs there for a
minute or so, and unittest does notice the subsequent:

Traceback (most recent call last):
  File "C:\Code\python\lib\unittest.py", line 260, in run
    testMethod()
  File "C:\Code\ZODB3.3\build\lib.win32-2.4\ZEO\tests\ConnectionTests.py",
line 458, in checkReconnection
    self.startServer(create=0)
  File "C:\Code\ZODB3.3\build\lib.win32-2.4\ZEO\tests\ConnectionTests.py",
line 202, in startServer
    zeoport, adminaddr, pid, path = forker.start_zeo_server(
  File "C:\Code\ZODB3.3\build\lib.win32-2.4\ZEO\tests\forker.py", line
149, in start_zeo_server
    s.connect(adminaddr)
  File "<string>", line 1, in connect
error: (10061, 'Connection refused')

failure.

Now somebody, for some reason, added this to 2.4's asyncore.py:

            if sys.platform == 'win32':
                reuse_constant = socket.SO_EXCLUSIVEADDRUSE
            else:
                reuse_constant = socket.SO_REUSEADDR

If I take away the new special case for Windows there, the
checkReconnection test works fine again.

Now I don't understand any of this.  Does anyone?  From the *looks* of
it, the error from bind() comes from trying to reuse an address, which
used to work fine, but no longer works at all on Windows -- at least
not in the way ZEO needs it to work.  ZEO calls set_reuse_addr()
because it needs to reuse ports quickly, and offhand it makes no sense
to me to change the meaing of set_reuse_addr() on Windows to something
that refuses to allow port reuse.


More information about the Python-Dev mailing list