Skip to content

Commit

Permalink
[service] Defend against logging error on close().
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisCummins committed Apr 20, 2022
1 parent 85d094f commit 2210f50
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions compiler_gym/service/connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,18 @@ def close(self) -> None:
if self.closed:
return

logger.debug(
"Closing the service connection pool with %d cached and %d live connections",
self.size,
len(self.allocated),
)
try:
logger.debug(
"Closing the service connection pool with %d cached and %d live connections",
self.size,
len(self.allocated),
)
except ValueError:
# As this method is invoked by the atexit callback, the logger
# may already have closed its streams, in which case a
# ValueError is raised.
pass

for connections in self.pool.values():
for connection in connections:
connection.shutdown()
Expand Down

0 comments on commit 2210f50

Please sign in to comment.