4 ms·
Trying out the last snippet. What am I doing wrong here? Python 3.7.7 https://pastebin.com/E9KWCmky https://pastebin.com/E9KWCmky
by natch 6y ago
Trying out the last snippet. What am I doing wrong here? Python 3.7.7
https://pastebin.com/E9KWCmky https://pastebin.com/E9KWCmky
- zeronone 6y agoIndentation is wrong in following statement ``` return once_wrapper ```
- natch 6y agoDuh, thanks! Now I have a new one but I think it just means the script needs to stay running longer so the coroutine can have time to do its thing. ./once.py:29: RuntimeWarning: coroutine 'once. <locals>.once_wrapper' was never awaited one_time_setup()
- prashnts 6y agoYour main function needs to be async as well, since the one_time_setup is async. Linking this SO answer that also links to the docs (may come handy!). https://stackoverflow.com/questions/57399157/runtimewarning-coroutine-main-was-never-awaited https://stackoverflow.com/questions/57399157/runtimewarning-... Edit: Also tangentially relevant is the article linked by pansa2 in another thread, which was also discussed on HN a few months ago: http://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ http://journal.stuffwithstuff.com/2015/02/01/what-color-is-y...
- natch 6y agoThanks!