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.

Title: 2.4 asyncore breaks Zope
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, rhettinger, tim.peters
Priority: high Keywords:

Created on 2004-08-18 17:19 by tim.peters, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
asyncore.patch akuchling, 2004-08-30 16:40 akuchling, 2004-09-01 13:32 Test program -- shows that duplicated fd's are listed twice in the output
Messages (10)
msg22118 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-08-18 17:19
Bug 629097 describes a thread race involving 
asyncore.pool(), and was closed with "so don't do that".

Polling exception sets is new in 2.4, though, and opens 
the same race to formerly safe uses:  leaving 
indeterminate junk in the socket map, provided that junk 
doesn't call itself readable or writable.  Such junk never 
got passed to select() before 2.4, but always gets 
passed to select() in 2.4.  This is incompatible behavior, 
albeit in a grey area.

More discussion starting at

msg22119 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-08-30 11:12
Logged In: YES 

The attached patch restores the behaviour that fds are only
checked if they're readable or writable.  However, even with
the patch the ZODB/ZEO tests still fail for me.
msg22120 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-08-30 16:36
Logged In: YES 

No patched is attached (you have to check the box, etc).

I was running Zope3 tests, and testManyClients specifically is 
what fails now (plus some irrelvant failures caused by the 
testManyClients failure).  testManyClients isn't a ZODB/ZEO 
test, BTW.  I didn't see any failures in ZODB/ZEO tests due 
to the asyncore change.
msg22121 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-08-30 16:40
Logged In: YES 

Attaching patch.
msg22122 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-08-30 16:49
Logged In: YES 

Logic similar to the logic in the patch worked for me when I 
tried it.  Suggest it would be faster and clearer to just add

    e = r + w

to the 2.3 asyncore poll().
msg22123 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-09-01 13:32
Logged In: YES 

'e = r+w' means 'e' can contain the same descriptor twice, 
if it's both readable and writable, and I think this
matters.  Duplicate fd's don't cause a problem with the
select() system call itself, but the return value from would include the file descriptor twice. 
(I've attached a test program that demonstrates this for
readable fds.)  

Therefore, I think the 'if is_r or is_w' logic is necessary.

msg22124 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-09-01 14:08
Logged In: YES 

Original patch committed as rev. 1.61 of  I'm
leaving the bug open until Tim (or someone) reports that the
problem is fixed.

poll2 (the one that uses select.poll()) should automatically
remove objects for which POLLNVAL is set -- that's what the
error means, after all.  I'll worry about that after
2.3alpha3 is released.

msg22125 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-09-12 03:25
Logged In: YES 

Zope3's problem w/ asyncore appears to be fixed.  Thanks!


> Therefore, I think the 'if is_r or is_w' logic is necessary.

I expect you're right.  I think I had vaguely in mind that "the 
usual" implementation of fdsets represents them as bit 
vectors, so that redundancy wouldn't hurt.  But that's not 
the only part of the story, and I overlooked that.
msg22126 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-09-25 17:50
Logged In: YES 

Tim, can this be marked as fixed and closed?
msg22127 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-09-28 02:28
Logged In: YES 

Yup, this is fixed as far as I'm concerned, so closing it.
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40780
2004-08-18 17:19:22tim.peterscreate