twisted / twisted/klein

Accessing the `installSignalHandlers` parameter of the `reactor.run()` method

Open
#674 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
838
Forks
123
Avg merge
7h 58m
Merged PRs (30d)
12

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/klein/_app.py around line 681 and inspect Klein.run(), especially how displayTracebacks is exposed before reactor.run() is called. Done means Klein.run() accepts an installSignalHandlers parameter and forwards it to reactor.run(); check the linked Twisted ReactorBase documentation for the parameter behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.