Skip to content

Weird behavior when Textual App started under multiprocessing.Process #601

Answered by frankie567
frankie567 asked this question in Q&A
Discussion options

You must be logged in to vote

After digging, I found the source of the problem and the issue. On macOS and Windows, when using multiprocess.Process, Python will spawn a new process, which creates new file descriptors, in particular for stdin.

Then, the LinuxDriver will be initialized inside the sub-process with this new stdin, different from the main process:

class LinuxDriver(Driver):
"""Powers display and input for Linux / MacOS"""
def __init__(self, console: "Console", target: "MessageTarget") -> None:
super().__init__(console, target)
self.fileno = sys.stdin.fileno()

Therefore, events won't be catched b…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by frankie567
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants