File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -313,10 +313,11 @@ async def _start():
313313 await make_discoverable (peer = peer )
314314 log .info ('Exited make_discoverable' )
315315 else :
316- log .warning ('No new peer created. An active peer already exists.' )
316+ log .warning ('Failed to create peer.' )
317+ return peer
317318
318319
319- async def _shutdown ():
320+ async def _shutdown (peer = None ):
320321 global _is_shutting_down
321322 _is_shutting_down = True
322323 if peer :
@@ -346,17 +347,17 @@ async def _shutdown():
346347 # coro = _run_offer(pc, signaling)
347348 # else:
348349 # coro = _run_answer(pc, signaling)
349- coro = _start
350350
351351 # run event loop
352352 loop = asyncio .get_event_loop ()
353353 try :
354- loop .run_until_complete (coro ())
355- loop .run_forever ()
354+ peer = await _start ()
355+ if peer :
356+ loop .run_forever ()
356357 except KeyboardInterrupt :
357358 log .info ('KeyboardInterrupt detected.' )
358359 finally :
359360 log .info ('Shutting down...' )
360- loop . run_until_complete ( _shutdown () )
361+ await _shutdown (peer = peer )
361362 loop .close ()
362363 log .info ('All done.' )
You can’t perform that action at this time.
0 commit comments