#30305: Feature to set the returncode of a django custom command
-------------------------------+--------------------------------------
Reporter: stephanm | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by stephanm):
* status: closed => new
* resolution: invalid =>
Comment:
Hi,
I stepped a little through the code after the `handle()` function returns.
Here I see in that I pass through the function
`django.core.management.base.BaseCommand.run_from_argv()`
which itself calls a `connections.close_all()` function at the end,
so using `sys.exit()` inside the `handle()` function will not give the
exact same
behaviour as a "controlled" exit.
Or do I miss something?
See:
[https://github.com/django/django/blob/2.1.8/django/core/management/base.py#L299
run_from_argv(self, argv)]
{{{#!python
def run_from_argv(self, argv):
try:
self.execute(*args, **cmd_options)
except Exception as e:
#....
finally:
try:
connections.close_all()
except ImproperlyConfigured:
# Ignore if connections aren't setup at this point (e.g. no
# configured settings).
pass
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30305#comment:2>
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.0bc6374e7e094f5d8cdab70a283d7db3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.