Issue 453099: select in asyncore not defensive (original) (raw)

The poll method in asyncore.py does not wrap the select.select call on line 86 in a try/except block to test for EINTR/EWOULDBLOCK and then try the select call again. This was brought to my attention during the perusal of the Zope-dev list. Seems like the person who originally reported the symptom did not open a bug so I thought I would.

Platform: SunOS 5.8/Sparc Python version: 2.1.1 Zope version: 2.4.0

Thanks.

Here is the mail from a person on the Zope-dev mailing list:

I am moving this thread over from the zope list in the hope that someone here may have more insight into the nature of this problem, and perhaps how to go about better diagnosing/fixing the problem.

To sum up: Under apparently random circumstances and rather mild amounts of traffic, Zope is crashing and printing the Traceback below to the console. This is Zope-2.4.0, Python-2.1.1 on SunOS 5.8/Sparc.

Traceback (most recent call last): File "/u01/zope/Zope-2.4.0-src/z2.py", line 774, in ? asyncore.loop() File "/u01/zope//lib/python2.1/asyncore.py", line 194, in loop poll_fun (timeout, map) File "/u01/zope//lib/python2.1/asyncore.py", line 86, in poll r,w,e = select.select (r,w,e, timeout) select.error: (4, 'Interrupted system call')

Logged In: NO

Sorry, the user's email is jziniti@speakeasy.org.

EWOULDBLOCK was reported by that user for a different method in asyncore called accept though it seems that EWOULDBLOCK is being handled correctly in accept. It seems that the user did add the try/except block around the select call on line 86 which resulted in later call to accept() throwing EWOULDBLOCK. The trace is as follows:

system.error 4((4, 'Interrupted system call'))

2001-08-16T13:16:01 ERROR(200) ZServer uncaptured python exception, closing channel <__repr__ (self) failed for object at dee7bc (addr='/tmp/zope.soc')> (exceptions.TypeError:unpack non-sequence [/u01/zope/lib/python2.1/asyncore.py|poll|101] [/u01/zope/lib/python2.1/asyncore.py|handle_read_event|383] [/u01/zope/Zope-2.4.0-src/ZServer/FCGIServer.py|handle_accept|697])

2001-08-16T13:16:01 ERROR(200) ZServer uncaptured python exception, closing channel <__repr__ (self) failed for object at dec4bc (addr='/u01/zope/Zope-2.4.0-src/var/pcgi.soc')> (exceptions.TypeError:unpack non-sequence [/u01/zope/lib/python2.1/asyncore.py|poll|101] [/u01/zope/lib/python2.1/asyncore.py|handle_read_event|383] [/u01/zope/Zope-2.4.0-src/ZServer/PCGIServer.py|handle_accept|380])

2001-08-16T13:16:01 ERROR(200) ZServer uncaptured python exception, closing channel (exceptions.TypeError:unpack non-sequence [/u01/zope/lib/python2.1/asyncore.py|poll|101] [/u01/zope/lib/python2.1/asyncore.py|handle_read_event|383] [/u01/zope/Zope-2.4.0-src/ZServer/FTPServer.py|handle_accept|694])

2001-08-16T13:16:01 PROBLEM(100) ZServer warning: server accept() threw EWOULDBLOCK

2001-08-16T13:16:01 ERROR(200) ZServer uncaptured python exception, closing channel <select-trigger (pipe) at 248024> (exceptions.OSError:[Errno 11] Resource temporarily unavailable [/u01/zope/lib/python2.1/asyncore.py|poll|101] [/u01/zope/lib/python2.1/asyncore.py|handle_read_event|389] [/u01/zope/Zope-2.4.0-src/ZServer/medusa/thread/select_trigger.py|handle_read|77] [/u01/zope/lib/python2.1/asyncore.py|recv|341] [/u01/zope/lib/python2.1/asyncore.py|recv|523])

Thanks.