[Zope3-dev] Win32 Tests - Zope 3 - Too many errors :-(

Tim Peters tim@zope.com
Mon, 23 Dec 2002 11:07:20 -0500


[Chris Withers, reporting Zope3 ZEO test failures]

They should all work for you now.  One other thing, though, specific to
Windows and Pythons in the 2.2 line:

> ==================================================================
> Python Version:2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)]
>
> Modules included:
> Zope3 (HEAD)
>
> Running tests from D:\ZopeTests\sandbox\Zope3
> checkReadOnlyFallbackWritable
> (ZEO.tests.testConnection.FileStorageConnectionTests)
> [<socket._socketobject instance at 0x0198DEF0>,
> <ManagedConnection ('127.0.0.1', 28372)>,
>  <socket._socketobject instance at 0x01EA4E68>,
>  <ManagedConnection ('127.0.0.1', ...
>  ...
> ]
> ...

These large lists are printed by the test driver, here:

    def stopTest(self, test):
        if gc.garbage:
            print test
            print gc.garbage

The problem is that sockets on Windows are hiding in a Python socket
wrapper, and that wrapper has a __del__ method.  The tests create cyclic
structures including these socket wrappers, and the __del__ method prevents
the cyclic structures from getting garbage-collected.  gc.garbage keeps
growing (and growing, and growing, ...) as a result.

It turns out there was no *reason* for the Windows socket wrapper to have a
__del__ method, and it's gone in Python 2.3.  Until Python 2.2.3 comes out
(if ever), if you're running ZEO tests on Windows under the 2.2 line, I
recommend commenting out the __del__ method in your Python source tree, in
Lib/socket.py:

...

class _socketobject:

    class _closedsocket:
        def __getattr__(self, name):
            raise error(9, 'Bad file descriptor')

    def __init__(self, sock):
        self._sock = sock

    def close(self):
        # Avoid referencing globals here
        self._sock = self.__class__._closedsocket()

## Comment out the next two lines.
##    def __del__(self):
##        self.close()

gc.garbage remains empty during the ZEO tests then.

If you don't do this, the tests should still pass, but printing the
ever-growing gc.garbage list adds a quadratic-time component to the time
needed to complete the tests (and wastes memory, of course).