Skip to content

threading.Thread is rather awkward to use #91876

Closed as not planned
Closed as not planned
@BarneyStratford

Description

@BarneyStratford

Feature or enhancement

I propose to add a new decorator, @thread, to threading. When called, a decorated function will start in its own thread and return the new thread to the caller.

Pitch

I find it awkward to write

t = threading.Thread (target = target, args = <something>, kwargs= <something>)
t.start ()
...
t.join ()

every time I want to run something in a new thread. It's especially awkward if the only calls to the target are from new threads. Instead, I'd prefer to write

@threading.thread 
def target (n):
    print ("Hello" * n)

t = target (3)
...
t.join ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions