billiard
billiard copied to clipboard
SoftTimeLimitExceeded inherits from Exception
Hi, I am curious about why SoftTimeLimitExceeded
inherits from Exception
and not BaseException
.
Usually it's completely fine to write code like this:
try:
x = something()
except Exception:
logger.exception('Ouch')
x = None
If it is normal script running in main thread, something like KeyboardInterrupt
just terminates the script. In celery when SoftTimeLimitExceeded
is raised, something
is interrupted, but script will continue with None
in x, so the script must be modified like this:
try:
x = something()
except SoftTimeLimitExceeded:
raise
except Exception:
logger.exception('Ouch')
x = None
Extending from BaseException
(or SystemExit
?) instead of Exception
would solve this issue.
bump :) anything I can help with ?
Me too am curious. I would expect the (Soft)TimeLimit exceptions to be on pair with SystemExit exception - at least if I understand the functionality correctly. Is there any plan to look into this and change this behaviour?
I also think this should be done, so should we make a PR? Or are any points against ?
I also ran into this issue where I was expecting to cancel a long-running task by using
revoke(task_id, terminate=True, signal='SIGUSR1')
I happened to run into this issue because I was using boto3
which has an Exception
catch block which wraps the original error.
It yielded the following:
botocore.exceptions.HTTPClientError: An HTTP Client raised an unhandled exception: SoftTimeLimitExceeded()
I suppose the issue at this point is that moving from Exception
to BaseException
is a breaking change.