Skip to content

Commit

Permalink
fix: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemDoum committed Feb 1, 2024
1 parent 6a9c904 commit 1622d09
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions neo4j-app/neo4j_app/icij_worker/backend/mp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import functools
import logging
import multiprocessing
import os
Expand Down Expand Up @@ -44,17 +43,16 @@ def _mp_work_forever(
worker.loop.run_until_complete(deps_cm.__aexit__(*sys.exc_info()))


def signal_handler(sig_num, *_, pool: multiprocessing.Pool):
def signal_handler(sig_num, *_):
logger.error(
"received %s, triggering process pool worker shutdown !",
signal.Signals(sig_num).name,
)


def setup_main_process_signal_handlers(pool: multiprocessing.Pool):
handler = functools.partial(signal_handler, pool=pool)
def setup_main_process_signal_handlers():
for s in _HANDLED_SIGNALS:
signal.signal(s, handler)
signal.signal(s, signal_handler)


@contextmanager
Expand Down Expand Up @@ -82,7 +80,7 @@ def run_workers_with_multiprocessing(
pool = mp_ctx.Pool(n_workers, maxtasksperchild=1)
logger.debug("Setting up signal handlers...")
if handle_signals:
setup_main_process_signal_handlers(pool)
setup_main_process_signal_handlers()
try:
for w_id in worker_ids:
kwds.update({"worker_id": w_id})
Expand Down

0 comments on commit 1622d09

Please sign in to comment.