Skip to content

Accessing the installSignalHandlers parameter of the reactor.run() method #674

Open
@Darnethal0z

Description

I don't know if it is done on purpose or not, but as it is we cannot access the installSignalHandlers parameter of the reactor.run() method (_app.py, line 681).

An additional parameter implemented in Klein.run() in the same manner as displayTracebacks would be a good addition.

Here is a raw Klein.run() method redefinition from _app.py to explain my point :

def run(
    self,
    host: Optional[str] = None,
    port: Optional[int] = None,
    logFile: Optional[IO] = None,
    endpoint_description: Optional[str] = None,
    displayTracebacks: bool = True,
    installSignalHandlers: bool = True,
) -> None:

    if logFile is None:
        logFile = sys.stdout

    log.startLogging(logFile)

    if not endpoint_description:
        endpoint_description = f"tcp:port={port}:interface={host}"

    endpoint = serverFromString(reactor, endpoint_description)

    site = Site(self.resource())
    site.displayTracebacks = displayTracebacks

    endpoint.listen(site)
    # Passing installSignalHandlers on the method call 
    reactor.run(installSignalHandlers=installSignalHandlers)  # type: ignore[attr-defined]

This is a really small modification, i may provide a proper PR if accepted.

Here is the affiliated Twister documentation page : https://docs.twistedmatrix.com/en/stable/api/twisted.internet.base.ReactorBase.html#run

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions