Last active
October 2, 2019 05:23
-
-
Save cowlicks/08f65799aeb1ed0d92988a017c5dd8f7 to your computer and use it in GitHub Desktop.
So you wanna run some asyncio code...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: | |
// dev with: dot -Tx11 this_file.dot | |
// output with: dot -Tpng this_file.dot > out_file.png | |
// change "png" above to desired output format | |
digraph asyncio { | |
"so you wanna run some asyncio code?" -> "do you want to run the code sequentially?"; | |
"do you want to run the code sequentially?" -> "are you within an async block?"[ label="yes" ]; | |
"are you within an async block?" -> "use await" [ label="yes" ]; | |
"are you within an async block?" -> "is there already an event loop running in the current thread?" [ label="no" ]; | |
"is there already an event loop running in the current thread?" -> "use asyncio.run" [ label="no" ]; | |
"is there already an event loop running in the current thread?" -> "that sucks, you gotta run it in another process and wait" [ label="yes" ]; | |
"do you want to run the code sequentially?" -> "is there an event loop running in the current process?"[ label="no" ]; | |
"is there an event loop running in the current process?" -> "use create task" [ label="yes" ]; | |
"is there an event loop running in the current process?" -> "run it in another thread" [ label="no" ]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment