Unverified Commit 565b05f0 authored by Byron Hsu's avatar Byron Hsu Committed by GitHub
Browse files

Use `atexit` hook to implicitly shutdown `Runtime` (#1595)

parent b6aad70a
...@@ -514,6 +514,9 @@ class Runtime: ...@@ -514,6 +514,9 @@ class Runtime:
"""See the arguments in server_args.py::ServerArgs""" """See the arguments in server_args.py::ServerArgs"""
self.server_args = ServerArgs(*args, log_level=log_level, **kwargs) 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 # Pre-allocate ports
for port in range(10000, 40000): for port in range(10000, 40000):
if is_port_available(port): if is_port_available(port):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment