luispedro / jug

Parallel programming with Python
https://jug.readthedocs.io
MIT License
412 stars 62 forks source link

`pdb` option doesn't seem to work #79

Closed markvdw closed 4 years ago

markvdw commented 4 years ago

I'd like to debug errors that occur when I run a jug script. However, adding the --pdb flag doesn't seem to have any effect.

$ jug execute --debug --pdb jug-init-inducing-fixedhyp.py
...
CRITICAL:root:Could not import file 'jug-init-inducing-fixedhyp.py' (error: too many values to unpack (expected 4))
Traceback (most recent call last):
  File ...

Am I misunderstanding the intended use of the --pdb option?

(Many thanks for the software, it's great)

luispedro commented 4 years ago

Glad you like the software.

Indeed, --pdb does not work if the error occurs when the file is first imported, only when the tasks are running. So, currently, this will work as expected:

from jug import TaskGenerator

@TaskGenerator
def raise_error(n):
    if n > 2:
        # <------ error while executing the Tasks: you will be dropped into a debugger
        raise ValueError()

for i in range(10):
    raise_error(i)

I suppose it is a reasonable request to have it work when the error occurs while importing, though.