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 Changed 13 years ago by Wil Tan

patch coming up..

comment:2 Changed 13 years ago by Jannis Leidel

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 Changed 13 years ago by Wil Tan

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 Changed 13 years ago by ed@…

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

comment:5 Changed 13 years ago by Wil Tan

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 Changed 12 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

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

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 Changed 12 years ago by bhuztez

Cc: bhuztez@… added

comment:9 Changed 11 years ago by Adam DePrince <deprince@…>

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 Changed 11 years ago by Aymeric Augustin

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

comment:11 Changed 11 years ago by Aymeric Augustin

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