Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition in asyncore poll #37371

Closed
steveazope mannequin opened this issue Oct 26, 2002 · 4 comments
Closed

Race condition in asyncore poll #37371

steveazope mannequin opened this issue Oct 26, 2002 · 4 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@steveazope
Copy link
Mannequin

steveazope mannequin commented Oct 26, 2002

BPO 629097
Nosy @gvanrossum, @akuchling

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/akuchling'
closed_at = <Date 2004-07-10.17:15:53.000>
created_at = <Date 2002-10-26.14:48:09.000>
labels = ['library']
title = 'Race condition in asyncore poll'
updated_at = <Date 2004-07-10.17:15:53.000>
user = 'https://bugs.python.org/steveazope'

bugs.python.org fields:

activity = <Date 2004-07-10.17:15:53.000>
actor = 'akuchling'
assignee = 'akuchling'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2002-10-26.14:48:09.000>
creator = 'stevea_zope'
dependencies = []
files = []
hgrepos = []
issue_num = 629097
keywords = []
message_count = 4.0
messages = ['12952', '12953', '12954', '12955']
nosy_count = 4.0
nosy_names = ['gvanrossum', 'akuchling', 'stevea_zope', 'klimkin']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue629097'
versions = ['Python 2.3']

@steveazope
Copy link
Mannequin Author

steveazope mannequin commented Oct 26, 2002

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

@steveazope steveazope mannequin closed this as completed Oct 26, 2002
@steveazope steveazope mannequin assigned akuchling Oct 26, 2002
@steveazope steveazope mannequin added stdlib Python modules in the Lib dir labels Oct 26, 2002
@gvanrossum
Copy link
Member

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?

@klimkin
Copy link
Mannequin

klimkin mannequin commented Feb 24, 2004

Logged In: YES
user_id=410460

Yup, closing file in separate thread is program's (not
asyncore) error.

@akuchling
Copy link
Member

Logged In: YES
user_id=11375

Closing this bug.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

2 participants