mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
add outgoing http webhook for queries
This commit is contained in:
@@ -51,6 +51,32 @@ def _patch_loop(loop):
|
||||
return tasks
|
||||
|
||||
|
||||
def _cancel_all_tasks(loop, tasks):
|
||||
to_cancel = [task for task in tasks if not task.done()]
|
||||
|
||||
if not to_cancel:
|
||||
return
|
||||
|
||||
for task in to_cancel:
|
||||
task.cancel()
|
||||
|
||||
loop.run_until_complete(
|
||||
asyncio.gather(*to_cancel, loop=loop, return_exceptions=True)
|
||||
)
|
||||
|
||||
for task in to_cancel:
|
||||
if task.cancelled():
|
||||
continue
|
||||
if task.exception() is not None:
|
||||
loop.call_exception_handler(
|
||||
{
|
||||
"message": "unhandled exception during asyncio.run() shutdown",
|
||||
"exception": task.exception(),
|
||||
"task": task,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _patched_run(main, *, debug=False):
|
||||
try:
|
||||
loop = get_running_loop()
|
||||
@@ -79,32 +105,6 @@ def _patched_run(main, *, debug=False):
|
||||
loop.close()
|
||||
|
||||
|
||||
def _cancel_all_tasks(loop, tasks):
|
||||
to_cancel = [task for task in tasks if not task.done()]
|
||||
|
||||
if not to_cancel:
|
||||
return
|
||||
|
||||
for task in to_cancel:
|
||||
task.cancel()
|
||||
|
||||
loop.run_until_complete(
|
||||
asyncio.gather(*to_cancel, loop=loop, return_exceptions=True)
|
||||
)
|
||||
|
||||
for task in to_cancel:
|
||||
if task.cancelled():
|
||||
continue
|
||||
if task.exception() is not None:
|
||||
loop.call_exception_handler(
|
||||
{
|
||||
"message": "unhandled exception during asyncio.run() shutdown",
|
||||
"exception": task.exception(),
|
||||
"task": task,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
# If local system's python version is at least 3.6, use the backported
|
||||
# asyncio runner.
|
||||
if RUNNING_PYTHON_VERSION >= (3, 6):
|
||||
|
Reference in New Issue
Block a user