Message10426

Author zyasoft
Recipients jeff.allen, zyasoft
Date 2015-11-01.18:31:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1446402692.17.0.675566941198.issue2420@psf.upfronthosting.co.za>
In-reply-to
Content
Jeff, this is very helpful in terms of using lsof to do this assessment. I too have noticed this problem, and it is because of using sockets.

I don't believe it's a fault in the socket module per se, which should be attempting to close out all Netty resources. But a lot of the tests rely on deterministic GC. So that's why test_socket, which previously would always reliably run out of files, uses the following function:

    def _assert_no_pending_threads(self, group, msg):
        # Ensure __del__ finalizers are called on sockets. Two things to note:
        # 1. It takes two collections for finalization to run.
        # 2. gc.collect() is only advisory to the JVM, never mandatory. Still 
        #    it usually seems to happen under light load.

        # Wait up to one second for there not to be pending threads

        for i in xrange(10):
            pending_threads = _check_threadpool_for_pending_threads(group)
            if len(pending_threads) == 0:
                break
            test_support.gc_collect()
            
        if pending_threads:
            print "Pending threads in Netty msg={} pool={}".format(msg, pprint.pformat(pending_threads))
        
Not running test_socket in the usual mix may be losing out on this attempt to do aggressive GC.

My expectation is that most Python code out there does the right thing and closes out resources like sockets. However, since the socket module does not support __enter__, __exit__, and I have code in the wild that does not do such closes, it's quite possible I'm wrongly hoping that!
History
Date User Action Args
2015-11-01 18:31:32zyasoftsetmessageid: <1446402692.17.0.675566941198.issue2420@psf.upfronthosting.co.za>
2015-11-01 18:31:32zyasoftsetrecipients: + zyasoft, jeff.allen
2015-11-01 18:31:32zyasoftlinkissue2420 messages
2015-11-01 18:31:30zyasoftcreate