Skip to content

Commit b59d070

Browse files
committed
[service] Defend against logging error on close().
1 parent e43c2bb commit b59d070

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

compiler_gym/service/connection_pool.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,18 @@ def close(self) -> None:
174174
if self.closed:
175175
return
176176

177-
logger.debug(
178-
"Closing the service connection pool with %d cached and %d live connections",
179-
self.size,
180-
len(self.allocated),
181-
)
177+
try:
178+
logger.debug(
179+
"Closing the service connection pool with %d cached and %d live connections",
180+
self.size,
181+
len(self.allocated),
182+
)
183+
except ValueError:
184+
# As this method is invoked by the atexit callback, the logger
185+
# may already have closed its streams, in which case a
186+
# ValueError is raised.
187+
pass
188+
182189
for connections in self.pool.values():
183190
for connection in connections:
184191
connection.shutdown()

0 commit comments

Comments
 (0)