Message218018
| Author |
gvanrossum |
| Recipients |
giampaolo.rodola, gvanrossum, pitrou, ryder.lewis, vstinner, yselivanov |
| Date |
2014年05月06日.20:53:52 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1399409633.14.0.593693411625.issue21447@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
The second error is easy to explain and fix: it's a race condition between the OS thread used to call getaddrinfo() and the main thread. The method _write_to_self() in selector_events.py is hopelessly naive. It should probably become something like this:
def _write_to_self(self):
csock = self._csock
if csock is not None:
try:
self._csock.send(b'x')
except OSError:
pass
It is possible that the main thread closes csock at any time, and calling send() on a closed socket will raise OSError with errno=9 (EBADF). Fortunately this is because close() sets the fd to -1; so there is no worry about reuse of the fd.
I will investigate the first traceback next. |
|