From 1335a6f043c51f9196097c91d2af36e5d92b4623 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 25 May 2021 09:20:58 -0400 Subject: [PATCH] Experiment: only disable SIGINT handling in children --- tractor/_actor.py | 8 ++++++++ tractor/_entry.py | 10 +++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tractor/_actor.py b/tractor/_actor.py index b072d40..f277826 100644 --- a/tractor/_actor.py +++ b/tractor/_actor.py @@ -1,5 +1,6 @@ """ Actor primitives and helpers + """ from collections import defaultdict from functools import partial @@ -11,6 +12,7 @@ import uuid import typing from typing import Dict, List, Tuple, Any, Optional, Union from types import ModuleType +import signal import sys import os from contextlib import ExitStack @@ -719,6 +721,12 @@ class Actor: for attr, value in parent_data.items(): setattr(self, attr, value) + # Disable sigint handling in children if NOT running in + # debug mode; we shouldn't need it thanks to our + # cancellation machinery. + if 'debug_mode' not in rvs: + signal.signal(signal.SIGINT, signal.SIG_IGN) + return chan, accept_addr except OSError: # failed to connect diff --git a/tractor/_entry.py b/tractor/_entry.py index 2f57048..da1f651 100644 --- a/tractor/_entry.py +++ b/tractor/_entry.py @@ -3,7 +3,6 @@ Sub-process entry points. """ from functools import partial from typing import Tuple, Any -import signal import trio # type: ignore @@ -15,7 +14,7 @@ log = get_logger(__name__) def _mp_main( - actor: 'Actor', # type: ignore + actor: 'Actor', # type: ignore # noqa accept_addr: Tuple[str, int], forkserver_info: Tuple[Any, Any, Any, Any, Any], start_method: str, @@ -54,16 +53,13 @@ def _mp_main( def _trio_main( - actor: 'Actor', # type: ignore + actor: 'Actor', # type: ignore # noqa *, parent_addr: Tuple[str, int] = None, ) -> None: """Entry point for a `trio_run_in_process` subactor. - """ - # Disable sigint handling in children; - # we don't need it thanks to our cancellation machinery. - signal.signal(signal.SIGINT, signal.SIG_IGN) + """ log.info(f"Started new trio process for {actor.uid}") if actor.loglevel is not None: