Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading