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: Race condition in asyncore poll
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, gvanrossum, klimkin, stevea_zope
Priority: normal Keywords:

Created on 2002-10-26 14:48 by stevea_zope, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (4)
msg12952 - (view) Author: Steve Alexander (stevea_zope) Date: 2002-10-26 14:48
In the following post to the Zope 3 developers' list, I
describe a race condition in the poll method of asyncore.

http://lists.zope.org/pipermail/zope3-dev/2002-October/003091.html

The problem is this:

There is a global dict socket_map. In the poll method,
socket_map is processed into appropriate arguments for
a select.select call. However, if a socket that is
represented socket_map is closed during the time
between the processing of socket_map and the
select.select call, that call will fail with a Bad File
Descriptor (EBADF) error.

One solution is to patch asyncore to catch EBADF errors
raised by select.select, and at that point see if the
file descriptors in the current version of socket_map 
are the same as in the processed data used for the
select.select call. If they are the same, re-raise the
error, otherwise, ignore the error.

In another email to the Zope 3 developers' list, Jeremy
Hylton queries whether there are any other similar
problems in asyncore.

http://lists.zope.org/pipermail/zope3-dev/2002-October/003093.html
msg12953 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-11-05 22:49
Logged In: YES 
user_id=6380

According to Jeremy, this is more a matter of "don't do that".

The right solution is to make sure that sockets are only
closed by the main thread (the thread running asyncore.loop()).

I wonder if we should just close this bug report?
msg12954 - (view) Author: Alexey Klimkin (klimkin) Date: 2004-02-24 12:03
Logged In: YES 
user_id=410460

Yup, closing file in separate thread is program's (not
asyncore) error.
msg12955 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-07-10 17:15
Logged In: YES 
user_id=11375

Closing this bug.
History
Date User Action Args
2022-04-10 16:05:47adminsetgithub: 37371
2002-10-26 14:48:09stevea_zopecreate