Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

multiprocessing.Process.start hangs when a Thread is waiting for input() #132276

Open
Labels
@jonas-wago

Description

@jonas-wago

Bug report

Bug description:

Actual behavior
Having a Thread running which is waiting for a user cli input lets a newely started multiprocessing Process hang until the user provides the cli input for the Thread once.

The target method of the Process will not get called until the input is provided.
After the user has provided the input for the thread, the target of the Process beginns executing.
Regardless if the Thread is now waiting for further user input, the target of the Process continues running.

Expected behavior
I would expect the target of the Process to begin executing directly whenstart gets called, regardless of any Thread waiting for user input.

Minimal example

fromthreadingimportThreadfrommultiprocessingimportProcessimporttimedefthread_worker():whileTrue:input()print(f"Thread:{time.time_ns()}")time.sleep(1)defprocess_worker():whileTrue:print(f"Process:{time.time_ns()}")time.sleep(1)defmain():t=Thread(target=thread_worker)t.start()p=Process(target=process_worker)p.start()whileTrue:print(f"Parent:{time.time_ns()}")time.sleep(1)if__name__=='__main__':main()
Parent: 1744127459390331500Parent: 1744127460391104200Parent: 1744127461391702600Parent: 1744127462391891200Parent: 1744127463391976800<-- User pressed <Enter> hereThread: 1744127463907895600Process: 1744127464027620700Parent: 1744127464392826400Process: 1744127465027796400Parent: 1744127465393627600Process: 1744127466028309500Parent: 1744127466394346500Process: 1744127467028522100Parent: 1744127467395162900<-- User pressed <Enter> hereThread: 1744127468003765700Process: 1744127468029055500Parent: 1744127468395581600Process: 1744127469029577600Parent: 1744127469395885500Process: 1744127470030224200Parent: 1744127470396392600Process: 1744127471030760100Parent: 1744127471396828100

I find it unexpected that before the first<-- User pressed <Enter> here there is no output of the Process.

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp