See some of the previous discussions on asyncio reentrancy.

https://mail.python.org/pipermail/async-sig/2019-March/thread.html

I do think there is some case for non rentrency and nested loop where
what you define here would block an outer loop, but most people
suggesting what you ask actually want re-entrency, which is not
possible there.

In your case test() would fail in a context where there is already a
running loo.

Also Explicit is better than implicit.
-- 
Matthias

On Fri, 12 Jun 2020 at 13:50, J. Pic <j...@yourlabs.org> wrote:
>
> Hi all,
>
> Currently, you can not use await outside an async function, the following 
> code:
>
>   async def lol():
>     return 'bar'
>
>   def test():
>     return await lol()
>
>   print(test())
>
> Will fail with: SyntaxError: 'await' outside async function
>
> Of course, you can use asyncio.run and then it works fine:
>
>   import asyncio
>
>   async def lol():
>     return 'bar'
>
>   def test():
>     return asyncio.run(lol())
>
>   print(test())
>
> Why not make using await do asyncio.run "behind the scenes" when called 
> outside async function ?
>
> Thank you in advance for your replies
>
> --
> ∞
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/LOCYSYVRKXI45QQJOLYGZV6H2CBYTB7F/
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/W2DWTSSVR22E6SXUR2TBSLRFXDKT7LLQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to