Nir Soffer added the comment: 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30931> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com