MCPcopy Create free account
hub / github.com/python-arq/arq / fix_cancel_remaining_task

Function fix_cancel_remaining_task

tests/conftest.py:147–162  ·  view source on GitHub ↗
(loop)

Source from the content-addressed store, hash-verified

145
146@pytest.fixture(name='cancel_remaining_task')
147def fix_cancel_remaining_task(loop):
148 async def cancel_remaining_task():
149 tasks = asyncio.all_tasks(loop)
150 cancelled = []
151 for task in tasks:
152 # in repr works in 3.7 where get_coro() is not available
153 if 'cancel_remaining_task()' not in repr(task):
154 cancelled.append(task)
155 task.cancel()
156 if cancelled:
157 print(f'Cancelled {len(cancelled)} ongoing tasks', file=sys.stderr)
158 await asyncio.gather(*cancelled, return_exceptions=True)
159
160 yield
161
162 loop.run_until_complete(cancel_remaining_task())
163
164
165class SetEnv:

Callers

nothing calls this directly

Calls 1

cancel_remaining_taskFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…