should python asyncio task always return something?
It may sound like a dumb questions but I could not find a clear answer .
I can read, in the asyncio doc here:
done()
Return True if the Task is done.A Task is done when the wrapped coroutine either returned a value, raised an exception, or the Task was cancelled.
does this mean that whatever coroutine I created , It must always return something and not simply end when the job is done ??
If yes , what is the most pythonic way to do it ?
return 0
or return None
?
Solution 1:
All python functions return None
upon completion if not explicitly provided a return value so you don't need to explicitly return anything. If you need to return early you can use just return
without any value which is equivalent to return None
.