Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert to asyncio.run #266

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mite/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ async def controller_report():
controller.report(sender.send)

try:
loop.run_until_complete(
asyncio.run(
asyncio.gather(
controller_report(), server.run(controller, controller.should_stop)
)
Expand All @@ -270,7 +270,7 @@ def runner(opts):
transport = _create_runner_transport(opts)
sender = _create_sender(opts)
loop = asyncio.get_event_loop()
loop.run_until_complete(_create_runner(opts, transport, sender.send).run())
asyncio.run(_create_runner(opts, transport, sender.send).run())
# Under rare conditions, we've seen a race condition on the runner's exit
# that leads to an exception like:
# RuntimeError: Event loop stopped before Future completed.
Expand All @@ -283,7 +283,7 @@ def runner(opts):
# give the loop 5 seconds to complete any network ops that are outstanding
# before calling the close method which will cancel any scheduled
# callbacks and should ensure that the porgrma exits cleanly.
loop.run_until_complete(asyncio.sleep(5))
asyncio.run(asyncio.sleep(5))
loop.close()


Expand All @@ -299,7 +299,7 @@ def prometheus_exporter(opts):
receiver.add_listener(prometheus_metrics.process)
_start_web_in_thread(opts)
loop = asyncio.get_event_loop()
loop.run_until_complete(receiver.run())
asyncio.run(receiver.run())


def setup_logging(opts):
Expand Down
2 changes: 1 addition & 1 deletion mite/cli/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ def generic_receiver(opts):
if process_raw_message:
receiver.add_listener(process_raw_message)

loop.run_until_complete(receiver.run())
asyncio.run(receiver.run())
2 changes: 1 addition & 1 deletion mite/cli/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def stats(opts):
stats = Stats(sender=agg_sender.send, include=include, exclude=exclude)
receiver.add_listener(stats.process)
loop = asyncio.get_event_loop()
loop.run_until_complete(receiver.run())
asyncio.run(receiver.run())