Experiment: only disable SIGINT handling in children
parent
8d003c5116
commit
1335a6f043
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue