diff --git a/neo/event.py b/neo/event.py index 3c0b05d1997a60218050af9eb828dbf2f29123f9..fbae97cc5c08d4e05b7952d688fdfaa0243e0f0b 100644 --- a/neo/event.py +++ b/neo/event.py @@ -178,18 +178,14 @@ class EpollEventManager(object): if fd in r_done_set: continue r_done_set.add(fd) + conn = self.connection_dict[fd] + conn.lock() try: - conn = self.connection_dict[fd] - except KeyError: - pass - else: - conn.lock() - try: - conn.readable() - finally: - conn.unlock() - if conn.hasPendingMessages(): - self._addPendingConnection(conn) + conn.readable() + finally: + conn.unlock() + if conn.hasPendingMessages(): + self._addPendingConnection(conn) w_done_set = set() for fd in wlist: diff --git a/neo/tests/testEvent.py b/neo/tests/testEvent.py index d3f67b3712c02d89a3cb830fbd80577e04bbc1c7..ecb46355a5fe6d87944a4959c1348223a328f664 100644 --- a/neo/tests/testEvent.py +++ b/neo/tests/testEvent.py @@ -114,7 +114,10 @@ class EventTests(NeoTestBase): w_connector = Mock({"getDescriptor" : 351621}) w_conn = Mock({'getConnector': w_connector}) em.register(w_conn) - em.epoll = Mock({"poll":((r_conn.getDescriptor(),),(w_conn.getDescriptor(),))}) + em.epoll = Mock({"poll":( + (r_connector.getDescriptor(),), + (w_connector.getDescriptor(),), + )}) em.poll(timeout=10) # check it called poll on epoll self.assertEquals(len(em.epoll.mockGetNamedCalls("poll")), 1)