on-internet
← Community

`except` doesn’t catch my custom exception raised inside `InterpreterPoolExecutor` (Python 3.14)

Stack Overflow ·

I swapped ThreadPoolExecutor for the new InterpreterPoolExecutor to get real parallelism for CPU-bound work. With the thread pool, my except BadInput catches bad items and skips them. With the interpreter pool, the same exception goes straight past the except and kills the script. The traceback even names the class <fake __main__>.BadInput. from concurrent.futures import InterpreterPoolExecutor class BadInput(Exception): pass def check(n): if n == 3: raise BadInput(f"bad value: {n}") return n * 2 if __name__ == "__main__": with InterpreterPoolExecutor(max_workers=2) as pool: try: print(list(po

Comments

Sign in or sign up to comment and upvote.

No comments yet.