From 498ee5c1b87c7d52f5e11eb72e685c13839944a9 Mon Sep 17 00:00:00 2001 From: Kanyon Edvall Date: Mon, 8 Jun 2020 22:05:56 -0500 Subject: [PATCH] Wrap console.runcode calls in async coroutines to ensure they are awaited --- Firmware/fibre/python/fibre/shell.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Firmware/fibre/python/fibre/shell.py b/Firmware/fibre/python/fibre/shell.py index d5e24d858..7aae8f707 100644 --- a/Firmware/fibre/python/fibre/shell.py +++ b/Firmware/fibre/python/fibre/shell.py @@ -2,6 +2,7 @@ import sys import platform import threading +import asyncio import fibre def did_discover_device(device, @@ -101,12 +102,12 @@ def launch_shell(args, interact = lambda: console.interact(banner='') # install hook to hide ChannelBrokenException - console.runcode('import sys') - console.runcode('superexcepthook = sys.excepthook') - console.runcode('def newexcepthook(ex_class,ex,trace):\n' + asyncio.run(console.runcode('import sys')) + asyncio.run(console.runcode('superexcepthook = sys.excepthook')) + asyncio.run(console.runcode('def newexcepthook(ex_class,ex,trace):\n' ' if ex_class.__module__ + "." + ex_class.__name__ != "fibre.ChannelBrokenException":\n' - ' superexcepthook(ex_class,ex,trace)') - console.runcode('sys.excepthook=newexcepthook') + ' superexcepthook(ex_class,ex,trace)')) + asyncio.run(console.runcode('sys.excepthook=newexcepthook')) # Launch shell