Skip to content

Commit

Permalink
fix: only register atexit when EventStreamRuntime is initialized (All…
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyaoww authored Dec 20, 2024
1 parent 3236602 commit cfbe77b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion openhands/runtime/impl/eventstream/eventstream_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def remove_all_runtime_containers():
remove_all_containers(CONTAINER_NAME_PREFIX)


atexit.register(remove_all_runtime_containers)
_atexit_registered = False


class EventStreamRuntime(Runtime):
Expand Down Expand Up @@ -109,6 +109,11 @@ def __init__(
attach_to_existing: bool = False,
headless_mode: bool = True,
):
global _atexit_registered
if not _atexit_registered:
_atexit_registered = True
atexit.register(remove_all_runtime_containers)

self.config = config
self._host_port = 30000 # initial dummy value
self._container_port = 30001 # initial dummy value
Expand Down

0 comments on commit cfbe77b

Please sign in to comment.