Skip to content

Commit

Permalink
HH-211058 protect listener task from gc destroying
Browse files Browse the repository at this point in the history
  • Loading branch information
712u3 committed Mar 25, 2024
1 parent 0a4eb10 commit a4f6528
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion frontik/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
PIPE_BUFFER_SIZE = 1000000
MESSAGE_HEADER_MAGIC = b'T1uf31f'
MESSAGE_SIZE_STRUCT = '=Q'
LISTENER_TASK = set() # keep task from garbage collector


@dataclass
Expand Down Expand Up @@ -177,7 +178,8 @@ def _worker_function_wrapper(worker_function, worker_listener_handler, read_fd,
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

loop.create_task(_worker_listener(read_fd, worker_listener_handler))
task = loop.create_task(_worker_listener(read_fd, worker_listener_handler))
LISTENER_TASK.add(task)
worker_function()


Expand Down

0 comments on commit a4f6528

Please sign in to comment.