Changing development server threads type.

181 views
Skip to first unread message

Moayad Mardini

unread,
Jun 3, 2014, 12:43:19 AM6/3/14
to django-d...@googlegroups.com
Hi,

The development server currently uses "non-daemon threads" for the socketserver, this has many bad side effects, as discussed in ticket #21773 ( https://code.djangoproject.com/ticket/21773 ).
The most annoying disadvantages of that are:
1) Longer time to restart, because the sever has to make sure everything is finished before it can auto-reload, I don't think this is a good behavior because since it's a development server, you are always intentionally causing the auto-reload.
2) If something goes wrong, like a bad view, there is no way to quit or restart the server, without manually killing its process from the OS.

I made a patch: https://github.com/django/django/pull/2690 that changes the default threads type of the server to be daemon threads, and introduced a command option "runserver --nodaemon" to use non-daemon threads if the user still prefers that for one reason or another.

I'm aware that the core developers are reluctant to merge any big change without a discussion first, so I'm asking about your opinions about that change and the patch.

Thanks a lot,

Moayad

Tim Graham

unread,
Jun 4, 2014, 10:29:38 AM6/4/14
to django-d...@googlegroups.com
I think we should try to move away from maintaining our own web server and focus our efforts on trying to integration with others like gunicorn (#21978).

Ramiro Morales

unread,
Jun 4, 2014, 12:41:53 PM6/4/14
to django-d...@googlegroups.com
On Wed, Jun 4, 2014 at 11:29 AM, Tim Graham <timog...@gmail.com> wrote:
> I think we should try to move away from maintaining our own web server and
> focus our efforts on trying to integration with others like gunicorn
> (#21978).

For this particular change I'd go with what Moayad proposes but
without the backward compatibility command line switch (assuming it
actually enhance the reloadind responsiveness).

This essentially reduces it to a one-liner.

I agree with Tim about being -1 on other kind of changes which mean
adding code to the development web server plus it maintenance burden
(like for the OS-specific FS change detection mechanism, moving the
console output to happen via logging, etc.).

Regards,

--
Ramiro Morales
@ramiromorales

Malcolm Box

unread,
Jun 5, 2014, 11:51:37 AM6/5/14
to django-d...@googlegroups.com


On Wednesday, 4 June 2014 17:41:53 UTC+1, Ramiro Morales wrote:
For this particular change I'd go with what Moayad proposes but
without the backward compatibility command line switch (assuming it
actually enhance the reloadind responsiveness).



I've tried the 1-liner version here on Mac OS X 10.9 and it provides a massive speedup to reload. I haven't noticed any adverse effects.

So I'd vote wholeheartedly for this change.

Malcolm 

Moayad Mardini

unread,
Jun 5, 2014, 4:40:32 PM6/5/14
to django-d...@googlegroups.com
Thank you all for the feedback and thanks Tim for the merge.

I'm very interested in the idea of integrating with Gunicorn. We can take things slowly with that integration (starting as suggested with just an option to use Gunicorn with runserver command), and limit modifying the current server code to (very) minor modifications and bug fixings.  

Moayad
Reply all
Reply to author
Forward
0 new messages