Last active
May 22, 2019 18:10
-
-
Save crawftv/1f752308d60ff560b533763f8637b278 to your computer and use it in GitHub Desktop.
execute asyncio tasks
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
| def execute_async_event_loop(min_song, max_song, song_urls): | |
| """ | |
| This function does something analogous to compiling the get_data_asynchronously function, | |
| Then it executes loop. | |
| 1. Call the get_data_function | |
| 2. Get the event_loop | |
| 3. Run the tasks (Much easier to understand in python 3.7, "ensure_future" was changed to "create_task") | |
| 4. Edge_list and top_interactions will be passed to the next functions | |
| """ | |
| future = asyncio.create_task( | |
| get_data_asynchronous(min_song, max_song, song_urls) | |
| ) | |
| loop = asyncio.get_event_loop() | |
| loop.run_until_complete(future) | |
| return song_urls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment