Skip to content

fix: replace bare except clauses with specific exception types (#3164)#3197

Open
paulxg12 wants to merge 1 commit into
Netflix:masterfrom
paulxg12:master
Open

fix: replace bare except clauses with specific exception types (#3164)#3197
paulxg12 wants to merge 1 commit into
Netflix:masterfrom
paulxg12:master

Conversation

@paulxg12
Copy link
Copy Markdown

Closes #3164 — replaces bare except: clauses in multicore_utils.py with specific exception types.

Changes in metaflow/multicore_utils.py:

  • Line 25: except:except ImportError: (py2/py3 cPickle compat pattern)
  • Line 69: except:except Exception: (child process error handler should allow SystemExit/KeyboardInterrupt to propagate to os._exit())

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 13, 2026

Greptile Summary

This PR replaces two bare except: clauses in metaflow/multicore_utils.py with specific exception types, improving Python exception-handling hygiene.

  • Line 25: except:except ImportError: for the cPickle/pickle import fallback — the correct and narrowest exception type for a missing module.
  • Line 69: except:except Exception: in the forked child-process handler — SystemExit and KeyboardInterrupt (both BaseException subclasses, not Exception) now bypass the except clause; however, the finally block unconditionally calls os._exit(), so the child process still terminates cleanly regardless. The only behavioural difference is that tracebacks for those two signals will no longer be printed.

Confidence Score: 5/5

Safe to merge — both changes narrow bare except: clauses to the appropriate exception types without altering the function's core invariant.

The except ImportError: change is strictly correct for a module-import fallback. The except Exception: change in the forked child is also correct: KeyboardInterrupt/SystemExit now bypass the except clause, but the finally block still calls os._exit() unconditionally, so the child process always terminates. The only observable difference is that tracebacks for those two signals are no longer printed in the child, which is actually the more appropriate behaviour in a forked subprocess.

No files require special attention.

Important Files Changed

Filename Overview
metaflow/multicore_utils.py Two bare except: clauses replaced with except ImportError: and except Exception:; both changes are correct and the finally/os._exit() invariant is preserved.

Reviews (1): Last reviewed commit: "fix: replace bare except clauses with sp..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace bare except clauses in multicore_utils with specific exceptions

2 participants