From a4f6528bc0b70de4a56662305145285f8df92498 Mon Sep 17 00:00:00 2001 From: Leonid Vinogradov Date: Mon, 25 Mar 2024 12:36:32 +0300 Subject: [PATCH] HH-211058 protect listener task from gc destroying --- frontik/process.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontik/process.py b/frontik/process.py index 08ec22b8b..b7d76199e 100644 --- a/frontik/process.py +++ b/frontik/process.py @@ -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 @@ -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()