Skip to content

Commit

Permalink
fix: move peer to local variable scope
Browse files Browse the repository at this point in the history
  • Loading branch information
ivelin committed Mar 24, 2020
1 parent 10ad6e1 commit 3afc680
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/peerjs/ext/http-proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,11 @@ async def _start():
await make_discoverable(peer=peer)
log.info('Exited make_discoverable')
else:
log.warning('No new peer created. An active peer already exists.')
log.warning('Failed to create peer.')
return peer


async def _shutdown():
async def _shutdown(peer=None):
global _is_shutting_down
_is_shutting_down = True
if peer:
Expand Down Expand Up @@ -346,17 +347,17 @@ async def _shutdown():
# coro = _run_offer(pc, signaling)
# else:
# coro = _run_answer(pc, signaling)
coro = _start

# run event loop
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(coro())
loop.run_forever()
peer = await _start()
if peer:
loop.run_forever()
except KeyboardInterrupt:
log.info('KeyboardInterrupt detected.')
finally:
log.info('Shutting down...')
loop.run_until_complete(_shutdown())
await _shutdown(peer=peer)
loop.close()
log.info('All done.')

0 comments on commit 3afc680

Please sign in to comment.