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: select in asyncore not defensive
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jhylton Nosy List: barry, jhylton, nobody
Priority: normal Keywords:

Created on 2001-08-19 22:24 by anonymous, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (5)
msg6067 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-08-19 22:24
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')

msg6068 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-08-19 22:47
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 <FTPServer listening :8021 at
debcec> (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.
msg6069 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2001-08-20 16:57
Logged In: YES 
user_id=12800

Assigning to Jeremy.
msg6070 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2001-09-11 17:45
Logged In: YES 
user_id=31392

I thkn the select() and poll() calls should be defensive and
be resumed as long as a timeout was specified and not yet
exceeded.  I'll check with Sam and see what he things.
msg6071 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2001-10-29 16:33
Logged In: YES 
user_id=31392

Fixed in rev 1 .25 of asyncore.py
History
Date User Action Args
2022-04-10 16:04:20adminsetgithub: 35007
2001-08-19 22:24:35anonymouscreate