Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`internet`.`_signals``

module documentation
(source)

This module is used to integrate child process termination into a reactor event loop. This is a challenging feature to provide because most platforms indicate process termination via SIGCHLD and do not provide a way to wait for that signal and arbitrary I/O events at the same time. The naive implementation involves installing a Python SIGCHLD handler; unfortunately this leads to other syscalls being interrupted (whenever SIGCHLD is received) and failing with EINTR (which almost no one is prepared to handle). This interruption can be disabled via siginterrupt(2) (or one of the equivalent mechanisms); however, if the SIGCHLD is delivered by the platform to a non-main thread (not a common occurrence, but difficult to prove impossible), the main thread (waiting on select() or another event notification API) may not wake up leading to an arbitrary delay before the child termination is noticed.

The basic solution to all these issues involves enabling SA_RESTART (ie, disabling system call interruption) and registering a C signal handler which writes a byte to a pipe. The other end of the pipe is registered with the event loop, allowing it to wake up shortly after SIGCHLD is received. See `_SIGCHLDWaker` for the implementation of the event loop side of this solution. The use of a pipe this way is known as the self-pipe trick.

From Python version 2.6, `signal.siginterrupt` and `signal.set_wakeup_fd` provide the necessary C signal handler which writes to the pipe to be registered with `SA_RESTART`.

Class | `SignalHandling` | The `SignalHandling` protocol enables customizable signal-handling behaviors for reactors.
Function | `installHandler` | Install a signal handler which will write a byte to `fd` when SIGCHLD is received.
Function | `isDefaultHandler` | Determine whether the SIGCHLD handler is the default or not.
Type Alias | `SignalHandler` | Undocumented
Interface | `_IWaker` | Interface to wake up the event loop based on the self-pipe trick.
Class | `_ChildSignalHandling` | Signal handling behavior which supports SIGCHLD for notification about changes to child process state.
Class | `_FDWaker` | The self-pipe trick<http://cr.yp.to/docs/selfpipe.html>, used to wake up the main loop from another thread or a signal handler.
Class | `_MultiSignalHandling` | An implementation of `SignalHandling` which propagates protocol method calls to a number of other implementations.
Class | `_SIGCHLDWaker` | `_SIGCHLDWaker` can wake up a reactor whenever `SIGCHLD` is received.
Class | `_SocketWaker` | The self-pipe trick<http://cr.yp.to/docs/selfpipe.html>, implemented using a pair of sockets rather than pipes (due to the lack of support in select() on Windows for pipes), used to wake up the main loop from another thread.
Class | `_UnixWaker` | This class provides a simple interface to wake up the event loop.
Class | `_WithoutSignalHandling` | A `SignalHandling` implementation that does no signal handling.
Class | `_WithSignalHandling` | A reactor core helper that can manage signals: it installs signal handlers at start time.

def installHandler(fd: `int`) -> `int`: (source)

Install a signal handler which will write a byte to `fd` when SIGCHLD is received.

This is implemented by installing a SIGCHLD handler that does nothing, setting the SIGCHLD handler as not allowed to interrupt system calls, and using `signal.set_wakeup_fd` to do the actual writing.

Parameters
fd:`int` | The file descriptor to which to write when SIGCHLD is received.
Returns
`int` | The file descriptor previously configured for this use.

def isDefaultHandler(): (source)

Determine whether the SIGCHLD handler is the default or not.

SignalHandler: `TypeAlias` = (source)

Undocumented

Value

    Callable[[int, Optional[FrameType]], None]