-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
The work decorator possibly makes it too easy to create threads.
If you don't know what you are doing (and sometimes even if you do) threads can be a footgun. I think we should make launching threads more explicit.
I think the decorator should accept a thread argument which will create a thread worker if set to True.
Without thread=True it should be an error to decorate a non-coroutine.
i.e. the following should be an error:
@work
def foo(...):
...To create a thread, it should be this:
@work(thread=True)
def foo(...):
...This should create a thread worker:
@work
async def foo(...):
...Note, this is a breaking change, which should be reflected in the CHANGELOG. It will also require an update to the docs.
ndevenish