Replace bare except with except Exception in task-sdk supervisor#69544
Replace bare except with except Exception in task-sdk supervisor#69544bramhanandlingala wants to merge 1 commit into
Conversation
|
Verified both hunks against head. In supervisor.py the handler is log.exception(...) then raise, and for_queue only raises Exception subclasses (InvalidCoordinatorError/ValueError, plus any failure from the dynamically import_string-loaded coordinator class), so narrowing bare except: to except Exception: is behavior-preserving for every real error. The only runtime effect is that KeyboardInterrupt/SystemExit no longer get an extra traceback logged on their way out -- note they were already re-raised by the |
Description
Issue #69441 flags exception handlers that catch overly broad types,
which can hide real errors or interfere with signal handling. I looked
for bare
except:clauses specifically, since those catch everythingincluding
KeyboardInterrupt/SystemExit. There were two left in therepo outside of tests/docs.
1. Task-SDK supervisor — the bare except around coordinator init
always re-raised afterward, so signals weren't actually swallowed, just
logged with a misleading traceback before exiting. Narrowed to
except Exception:so real errors are still logged the same way, butCtrl+C/shutdown no longer produce that spurious log line.
2. Pytest plugin — a bare
except: raisethat did nothing (purere-raise, no logging). Removed it; the
finallybelow already handlescleanup.
Didn't touch the other
except Exception:blocks in core — those don'thave this bare-except issue, and a full rewrite is a separate effort.
related: #69441