Use atexit hook to implicitly shutdown Runtime (#1595)

This commit is contained in:
Byron Hsu
2024-10-06 22:18:45 -07:00
committed by GitHub
parent b6aad70ab1
commit 565b05f02f

View File

@@ -514,6 +514,9 @@ class Runtime:
"""See the arguments in server_args.py::ServerArgs"""
self.server_args = ServerArgs(*args, log_level=log_level, **kwargs)
# before python program terminates, call shutdown implicitly. Therefore, users don't have to explicitly call .shutdown()
atexit.register(self.shutdown)
# Pre-allocate ports
for port in range(10000, 40000):
if is_port_available(port):