Opened 12 years ago
Closed 12 years ago
#20445 closed Bug (fixed)
BaseCommand --traceback should raise the original Exception
Reported by: | jorgebastida | Owned by: | jorgebastida |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When you are debugging long-running process that take hours to finish is really helpful to run them using ipython --pdb <script>
so in case of failure, you'll get a ipdb trace just before the Exception was raised, so you can check what was wrong and fix it instead of adding an ipdb
and re running the script.
As for the last weeks I've been writing some django command that takes hours to run I tried to run these scripts using ipython --pdb manage.py <command>
but unfortunately I found that BaseCommand.run_from_argv
was capturing any Exception raised by my command and printing the traceback to stderr
if the --traceback
option was present, or name and error if not.
In order to use ipython --pdb
I need to override run_from_argv
In my commands and basically don't try/except self.execute(*args, **options.__dict__)
what is pretty hacky.
After talking with Russell Keith-Magee we found that, as python default behavior is to print the traceback into stderr}} and return an error status code when an Exception is raised and not captured, the solution would probably be to {{{raise
the Exception if --traceback
is present. The consequences are:
a) The existing behavior doesn't change.
b) We can call manage.py
commands from interpreters that do fancy things when exceptions are raised.
I haven't found anything related in the "Better Error Message" wiki page: https://code.djangoproject.com/wiki/BetterErrorMessages
Change History (6)
comment:1 by , 12 years ago
Status: | new → assigned |
---|
comment:2 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 12 years ago
comment:4 by , 12 years ago
Has patch: | set |
---|
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Pull request available here https://github.com/django/django/pull/1137