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.

Author vstinner
Recipients Nir Soffer, giampaolo.rodola, vstinner, walkhour
Date 2017-07-25.22:51:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1501023091.27.0.766578489338.issue30931@psf.upfronthosting.co.za>
In-reply-to
Content
If I understood correctly, to fix this race condition, there are two main constraints:

(A) We must call handlers of dispatcher registered before calling select()/poll(): dispatchers can be closed and their file descriptor can be reused while we execute other dispatchers

(B) Don't call closed dispatcher

--

For (A), I only see one option: copy somehow the map, for example using: ready = [(map[fd], flags) for fd, flags in r]

--

For (B), it's more tricky.

The bpo-30985 proposes to start using the closing: I'm not sure that it's doable in a stable version like 3.6, or worse in 2.7, since existing code may use closing differently.
http://bugs.python.org/issue30985#msg299154

I'm also concerned about subclassing: if a subclass overrides *completely* close(), we would fail to detect that the dispatcher was closed. Maybe this corner doesn't occur in the wild?

I see a different approach: while iterating on "ready" objects, check again if map.get(fd) still is the expected dispatcher. If the file descriptor is no more registered in map: it was closed. If we get a new dispatcher: not only the previous dispatcher was closed, but a new dispatcher also got the same file descriptor and was registered in the map.

Do you think that this approach would work? Would it be safer in term of backward compatibility?
History
Date User Action Args
2017-07-25 22:51:31vstinnersetrecipients: + vstinner, giampaolo.rodola, Nir Soffer, walkhour
2017-07-25 22:51:31vstinnersetmessageid: <1501023091.27.0.766578489338.issue30931@psf.upfronthosting.co.za>
2017-07-25 22:51:31vstinnerlinkissue30931 messages
2017-07-25 22:51:31vstinnercreate