use asyncio get/new_event_loop as recommended

This commit is contained in:
Sebastien Bourdeauducq 2022-05-31 22:25:43 +08:00
parent 8bf6bc4d1f
commit ca614a3eea
7 changed files with 18 additions and 12 deletions

View File

@ -76,7 +76,8 @@ def main():
args = get_argparser().parse_args()
common_args.init_logger_from_args(args)
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
signal_handler = SignalHandler()
signal_handler.setup()

View File

@ -196,7 +196,8 @@ def main():
bind_address = common_args.bind_address_from_args(args)
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
signal_handler = SignalHandler()
signal_handler.setup()

View File

@ -245,7 +245,8 @@ def _show_datasets(datasets):
def _run_subscriber(host, port, subscriber):
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(subscriber.connect(host, port))
try:

View File

@ -74,7 +74,8 @@ class MasterConfig:
def main():
args = get_argparser().parse_args()
log_forwarder = init_log(args)
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
atexit.register(loop.close)
signal_handler = SignalHandler()
signal_handler.setup()

View File

@ -21,7 +21,8 @@ def get_argparser():
def main():
args = get_argparser().parse_args()
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
signal_handler = SignalHandler()
signal_handler.setup()

View File

@ -28,7 +28,8 @@ class MonInjTest(ExperimentCase):
def injection_status_cb(channel, override, value):
injection_statuses.append((channel, override, value))
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
moninj_comm = CommMonInj(monitor_cb, injection_status_cb)
loop.run_until_complete(moninj_comm.connect(core_host))

View File

@ -10,11 +10,11 @@
]
},
"locked": {
"lastModified": 1654001815,
"narHash": "sha256-wMVXlnMh64cWfG0LNpDExAGL5iHNoCstmVkOVr31NSE=",
"lastModified": 1654007592,
"narHash": "sha256-vaDFhE1ItjqtIcinC/6RAJGbj44pxxMUEeQUa3FtgEE=",
"owner": "m-labs",
"repo": "artiq-comtools",
"rev": "2b4899ecddfaac160f92341377262ac61d6329b7",
"rev": "cb73281154656ee8f74db1866859e31bf42755cd",
"type": "github"
},
"original": {
@ -73,11 +73,11 @@
]
},
"locked": {
"lastModified": 1654001788,
"narHash": "sha256-vUSep33N66pcvy7ojnBLSmyyVfN20+WZvP/c4b0T2CI=",
"lastModified": 1654006751,
"narHash": "sha256-OWAnoTCutvTQcYdtdtLQuL6uRtG+7Jz7sbRhcScv8bo=",
"owner": "m-labs",
"repo": "sipyco",
"rev": "951de4cf198419712ea3f52991d8f9293f3d9d15",
"rev": "b3d03a94c751a24769c54a61a0dbe9d6af52dade",
"type": "github"
},
"original": {