Skip to content

threading.Thread: Add start=False parameter to start immediately the thread #155334

Open

Description

@vstinner

It's common to create multiple threads, start them, and then join them. Example:

threads = [
    threading.Thread(target=run_a),
    threading.Thread(target=run_b),
]
for thread in threads:
    thread.start()
...
for thread in threads:
    thread.join()

I propose adding a start=False parameter to threading.Thread to start immediately the thread. The example would become:

threads = [
    threading.Thread(target=run_a, start=True),
    threading.Thread(target=run_b, start=True),
]
...
for thread in threads:
    thread.join()

The new parameter would solve the old issue gh-93293 which requests to return self in start(). The issue example:

threads = []
for i in range(10):
  thread = threading.Thread(target=fn, args=(i,))
  thread.start()
  threads.append(thread)

for t in threads:
  t.join()

would become:

threads = [threading.Thread(target=fn, args=(i,), start=True) for i in range(10)]

for t in threads:
  t.join()

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Aug 7, 2026
  2. vstinner commented on Aug 7, 2026

    @vstinner
    MemberAuthor

    Adding a start parameter was mentioned in https://discuss.python.org/t/add-a-threading-run-convenience-function/108430 discussion.

  3. ZeroIntensity commented on Aug 9, 2026

    @ZeroIntensity
    Member

    I think threading.run/threading.run_daemon would be better, because the ergonomics of group (see #155348), args, and kwargs are bad. Constructors should also generally not perform expensive operations.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions