Opened 13 years ago

Closed 11 years ago

#16049 closed New feature (duplicate)

Make runserver reuse listening socket

Reported by: Wil Tan Owned by: anonymous
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: Jannis Leidel, bhuztez@…, deprince@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When using autoreload mode of runserver, there is a small window of time between restarts that the port is not bound. This disrupts the workflow because one has to wait for the server to come back up before being able to reload the browser to see code changes reflected.

We can reuse the listening socket's file descriptor by having the parent create the socket, and passing it to the child (where the real web server is run.)

A proof-of-concept is available on https://github.com/wil/django-pserver

Change History (11)

comment:1 by Wil Tan, 13 years ago

patch coming up..

comment:2 by Jannis Leidel, 13 years ago

Triage Stage: UnreviewedAccepted

I like the idea but am not sure what the side effects could be, e.g. sockets that are kept open when the server crashes.

comment:3 by Wil Tan, 13 years ago

Currently when server crashes, we'll have to Ctrl-C to kill the entire process anyway right? It should behave the same way, when the server starts up and crashes, there's not much we can do about it. except to kill it. I agree though, that we should be aware of side effects, can't say I've thought it through. Hopefully we can get some feedback from users of django-pserver.

comment:4 by ed@…, 13 years ago

Windows users don't have socked.fromfd() method which is used in the version of django-pserver. - ed

comment:5 by Wil Tan, 13 years ago

Yeah I was planning to specifically test for win32, use hasattr(socket, "fromfd") or try-except, then disable the function accordingly. Ugly, but I can't think of a better way.

comment:6 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

in reply to:  5 comment:7 by bhuztez, 12 years ago

Replying to dready:

Yeah I was planning to specifically test for win32, use hasattr(socket, "fromfd") or try-except, then disable the function accordingly. Ugly, but I can't think of a better way.

Python 3 do have socket.fromfd on Windows. Ridiculously, Issue 1378 got closed without patch actually applied to Python 2. I guess it is better fixed in Python.

http://bugs.python.org/issue1378

comment:8 by bhuztez, 12 years ago

Cc: bhuztez@… added

comment:9 by Adam DePrince <deprince@…>, 12 years ago

Cc: deprince@… added
Owner: changed from nobody to anonymous
Status: newassigned

Is there any objection to making this django feature contingent upon http://bugs.python.org/issue1378 for our windows users?

comment:10 by Aymeric Augustin, 11 years ago

I'm closing this ticket in favor of #18855 which has a good-looking patch.

comment:11 by Aymeric Augustin, 11 years ago

Resolution: duplicate
Status: assignedclosed
Note: See TracTickets for help on using tickets.
Back to Top