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 Nir Soffer
Recipients Nir Soffer, giampaolo.rodola, vstinner, walkhour
Date 2017-07-27.20:47:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1501188470.35.0.795180407709.issue30931@psf.upfronthosting.co.za>
In-reply-to
Content
Victor, I mostly agree with you, but I think we have here several bugs, and
we should do the minimal fix for each of them. Your PR is too big, trying
to fix too much.

(Bug 1) The dispatcher A closes the dispatcher B. Currently, asyncore calls the handlers of the dispatcher B.

We don't have such bug now - if dispatcher B is closed, it is not in the map, 
and current code will skip the fd when checking:

    for fd in r:
        obj = map.get(fd)
        if obj is None:
            continue

(Bug 2) Dispatcher A close Dispatcher B, create Dispatcher C. C get may use the same
fd as B. If B was ready, asyncore may get C from the map and access it instead of B.

This issue is reported in this bug.

(Bug 3) if handle_read() closed the dispatcher, asyncore will call handle_write() on
a closed dispatcher. This is a very old bug with asyncore.readwrite().

(Bug 4) handle_xxx_event() internal methods may call multiple handle_xxx() user
methods, again not checking if dispatcher was closed after each invocation.
Same, very old bug.

So I suggest that we fix *only* bug 2 in https://github.com/python/cpython/pull/2854.

The issue in readwrite() can be solved with the approach you suggest, but I prefer
to make small an careful steps so we don't introduce regressions in stable versions.

Also, there is already too much noise here an in the various PRs about this issue,
better file bugs for the rest of the issues and discuss them separately.

This commit
https://github.com/python/cpython/pull/2854/commits/bbd2d09ab999fa2214cbbd2589ae3642facd3057

Looks fine with the test_poll_close_replace_dispatchers test added in the later
commit.
History
Date User Action Args
2017-07-27 20:47:50Nir Soffersetrecipients: + Nir Soffer, vstinner, giampaolo.rodola, walkhour
2017-07-27 20:47:50Nir Soffersetmessageid: <1501188470.35.0.795180407709.issue30931@psf.upfronthosting.co.za>
2017-07-27 20:47:50Nir Sofferlinkissue30931 messages
2017-07-27 20:47:50Nir Soffercreate