Hi,

Executive summary : everything's in the subject line.

Boring details :

I have a Django application where I use a lot of custom commands, most being designed to be launched mostly by cron-jobs or other bash scripts of some sorts. In this respect, the exit code value may be of utmost importance.

Up until now, as I focused on the business logic part, when things went wrong I just raised exceptions so that the return code was set to 1. So good so far. The problem is the output is rather uselessly verbose then. I'm in the process of fixing things up in order to have some more concise output on failures.

It seems to me I once read in the doc that one should not use sys.exit() in custom commands, but can't find exactly where it was - but I found some allusions about this in StackOverflow comments. Yet I just sgoogumbled on this ticket https://code.djangoproject.com/ticket/25419 where it seems safe to use it.

AFAIAC, I would be using sys.exit() almost exclusively at the top level inside the handle() method, while testing sub-routines return values of catching exceptions. Tests I've run seems show this is working as I'd expected, but I'd like to be sure there is no hidden traps before to deploy this code on the production server.

So what is your take on this question ?

Thanks in advance,

phep

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a8d9c37d-cded-fb7d-a5bf-b3f6cf395fd1%40wakzo.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to