|
31 | 31 | from asyncio import Event, TimeoutError, Queue, ensure_future, \ |
32 | 32 | gather, sleep, wait_for, create_subprocess_exec, subprocess, \ |
33 | 33 | wait, FIRST_COMPLETED, Lock, as_completed, new_event_loop, \ |
34 | | - get_event_loop_policy, CancelledError # noqa |
35 | | - |
36 | | - |
37 | | -try: |
38 | | - from asyncio import get_running_loop |
39 | | -except ImportError: |
40 | | - def get_running_loop(): |
41 | | - loop = asyncio.get_event_loop() |
42 | | - if not loop.is_running(): |
43 | | - raise RuntimeError("no running event loop") |
44 | | - return loop |
45 | | - |
46 | | -try: |
47 | | - from asyncio import create_task |
48 | | -except ImportError: |
49 | | - def create_task(coro): |
50 | | - return asyncio.ensure_future(coro) |
| 34 | + get_event_loop_policy, CancelledError, get_running_loop, \ |
| 35 | + create_task # noqa |
| 36 | + |
| 37 | +# No more workaround for these imports |
| 38 | +# try: |
| 39 | +# from asyncio import get_running_loop |
| 40 | +# except ImportError: |
| 41 | +# def get_running_loop(): |
| 42 | +# loop = asyncio.get_event_loop() |
| 43 | +# if not loop.is_running(): |
| 44 | +# raise RuntimeError("no running event loop") |
| 45 | +# return loop |
| 46 | + |
| 47 | +# try: |
| 48 | +# from asyncio import create_task |
| 49 | +# except ImportError: |
| 50 | +# def create_task(coro): |
| 51 | +# return asyncio.ensure_future(coro) |
51 | 52 |
|
52 | 53 |
|
53 | 54 | def create_task_with_handler(coro, task_name, logger=ROOT_LOGGER): |
|
0 commit comments