Skip to content

Commit b364fd4

Browse files
committed
Catch BaseException, not only Exception
In theory, this casts a wider net. The goal is to reduce the occurrence of mysterious "thread death" errors where a task thread dies without setting its finished flag.
1 parent d892f06 commit b364fd4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/appose/python_worker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def _run(self) -> None:
150150
# Script produced a non-dict; add it alone to the outputs.
151151
self.outputs["result"] = result
152152
self._report_completion()
153-
except Exception:
153+
except BaseException:
154154
self.fail(traceback.format_exc())
155155

156156
def _report_launch(self) -> None:
@@ -177,7 +177,7 @@ def _respond(self, response_type: ResponseType, args: Args | None) -> None:
177177
# NB: Flush is necessary to ensure service receives the data!
178178
try:
179179
print(encode(response), flush=True)
180-
except Exception:
180+
except BaseException:
181181
if already_terminated:
182182
# An exception triggered a failure response which
183183
# then triggered another exception. Let's stop here
@@ -278,7 +278,7 @@ def main() -> None:
278278
exec(init_code, globals())
279279
# Clean up the temp file
280280
os.remove(init_script_path)
281-
except Exception as e:
281+
except BaseException as e:
282282
print(f"[WARNING] Init script failed: {e}", file=sys.stderr)
283283

284284
Worker().run()

0 commit comments

Comments
 (0)