Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[service] Defend against logging error on close().
Browse files Browse the repository at this point in the history
ChrisCummins committed Mar 7, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 8576f96 commit 23d3992
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
@@ -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()

0 comments on commit 23d3992

Please sign in to comment.