Skip to content

Commit

Permalink
Fix non-exception-safe finally: handlers.
Browse files Browse the repository at this point in the history
Fixes #1013.
  • Loading branch information
whitequark authored and sbourdeauducq committed May 25, 2018
1 parent 5f3cb12 commit e7b3876
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion artiq/protocols/logging.py
Expand Up @@ -168,6 +168,7 @@ def emit(self, record):
self._queue.put_nowait(record.source + ":" + self.format(record))

async def _do(self):
reader = writer = None
while True:
try:
reader, writer = await asyncio.open_connection(self.host,
Expand All @@ -182,4 +183,5 @@ async def _do(self):
except:
await asyncio.sleep(self.reconnect_timer)
finally:
writer.close()
if writer is not None:
writer.close()
3 changes: 2 additions & 1 deletion artiq/protocols/pc_rpc.py
Expand Up @@ -243,7 +243,8 @@ def close_rpc(self):
No further method calls should be done after this method is called.
"""
self.__writer.close()
if self.__writer is not None:
self.__writer.close()
self.__reader = None
self.__writer = None
self.__target_names = None
Expand Down

0 comments on commit e7b3876

Please sign in to comment.