Skip to content

Commit

Permalink
refactor: Prefer using create_task to old style ensure_future.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcass77 committed Aug 4, 2020
1 parent 0e11885 commit 919327e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion run_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
async def graceful_shutdown(pipeline, sig_name=None):
if _shutting_down.is_set():
# Only try to shut down once
logger.warning(f"Shutdown already in progress! Ignoring signal '{sig_name}'.")
return

_shutting_down.set()
Expand Down Expand Up @@ -82,7 +83,7 @@ async def main():
for sig_name in {"SIGINT", "SIGTERM"}:
loop.add_signal_handler(
getattr(signal, sig_name),
lambda: asyncio.ensure_future(
lambda: asyncio.create_task(
graceful_shutdown(fix_pipeline, sig_name=sig_name)
),
)
Expand Down

0 comments on commit 919327e

Please sign in to comment.