#20445: BaseCommand --traceback should raise the original Exception
--------------------------------------------+--------------------------
     Reporter:  jorgebastida                |      Owner:  jorgebastida
         Type:  Bug                         |     Status:  new
    Component:  Core (Management commands)  |    Version:  master
     Severity:  Normal                      |   Keywords:
 Triage Stage:  Unreviewed                  |  Has patch:  0
Easy pickings:  0                           |      UI/UX:  0
--------------------------------------------+--------------------------
 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

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20445>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to