Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Darnethal0z opened this issue Sep 27, 2023 · 1 comment

Comments

@Darnethal0z
Copy link

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

@Darnethal0z
Copy link
Author

Just opened the PR #675

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant