Skip to content

Commit 8299a1b

Browse files
committed
badgeware: Fix on_exit.
Since __import__ would never return in blocking apps, app would never get set. Retrieve on_exit from sys.modules instead.
1 parent f80d2c7 commit 8299a1b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

modules/common/badgeware/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ def __call__(self, update):
6464

6565

6666
def launch(path):
67-
app = None
68-
6967
def do_exit():
70-
on_exit = getattr(app, "on_exit", None)
71-
return on_exit() if callable(on_exit) else on_exit
68+
if path in sys.modules:
69+
app = sys.modules[path]
70+
on_exit = getattr(app, "on_exit", None)
71+
return on_exit() if callable(on_exit) else on_exit
72+
return None
7273

7374
def quit_to_launcher(_pin):
7475
do_exit()
@@ -84,7 +85,7 @@ def quit_to_launcher(_pin):
8485
try:
8586
os.chdir(path)
8687
sys.path.insert(0, path)
87-
app = __import__(path) # App may block here
88+
__import__(path) # App may block here
8889

8990
return do_exit()
9091

0 commit comments

Comments
 (0)