From e8b99addbd41a3d420afadfa367231df9ff8a6d4 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 27 Oct 2014 00:30:28 +0200 Subject: [PATCH] uasyncio: Ignore ENOENT on remove_writer(). StreamWriter.awrite() first tries to write to an fd, and if that succeeds, yield IOWrite may never be called for that fd, and it will never be added to poller. So, ignore such error. --- uasyncio/uasyncio/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/uasyncio/uasyncio/__init__.py b/uasyncio/uasyncio/__init__.py index c3ab7896..058b15b1 100644 --- a/uasyncio/uasyncio/__init__.py +++ b/uasyncio/uasyncio/__init__.py @@ -28,7 +28,15 @@ class EpollEventLoop(EventLoop): def remove_writer(self, fd): if __debug__: log.debug("remove_writer(%s)", fd) - self.poller.unregister(fd) + try: + self.poller.unregister(fd) + except OSError as e: + # StreamWriter.awrite() first tries to write to an fd, + # and if that succeeds, yield IOWrite may never be called + # for that fd, and it will never be added to poller. So, + # ignore such error. + if e.args[0] != errno.ENOENT: + raise def wait(self, delay): if __debug__: