Re: [Django] #8413: Django doesn't reload itself after updating files on disk that raised error on import.

26 views
Skip to first unread message

Django

unread,
Dec 11, 2011, 1:42:35 PM12/11/11
to django-...@googlegroups.com
#8413: Django doesn't reload itself after updating files on disk that raised error
on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: new
Component: Core (Management | Version: SVN
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* needs_better_patch: 0 => 1
* ui_ux: => 0
* easy: => 0
* stage: Design decision needed => Accepted


Comment:

Accepting the patch because the submitter addressed Malcolm's comment.

Unfortunately the GitHub link is broken, and the previous patch needs
updating — at least, we no longer need Python 2.3 compatibility.

--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 11, 2011, 2:04:09 PM12/11/11
to django-...@googlegroups.com
#8413: Django doesn't reload itself after updating files on disk that raised error
on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: new
Component: Core (Management | Version: SVN
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by aaugustin):

This problem was also reported in #9589. This ticket has patches but their
approach was rejected by a core dev and a BDFL.

--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:10>

Django

unread,
Dec 12, 2011, 3:08:21 AM12/12/11
to django-...@googlegroups.com
#8413: Django doesn't reload itself after updating files on disk that raised error
on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: new
Component: Core (Management | Version: SVN
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by carljm):

Replying to [comment:10 aaugustin]:

> This problem was also reported in #9589. This ticket has patches but
their approach was rejected by a core dev and a BDFL.

I don't think that's accurate - the initial patch there was rejected (for
good reason), but there are two subsequent patches that take quite a
different (and, at least at first glance, much better) approach; there's
no evidence those patches were ever given review. I think the second two
patches on #9859 deserve another look if someone does look into fixing
this.

--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:11>

Django

unread,
Dec 12, 2011, 6:02:11 AM12/12/11
to django-...@googlegroups.com
#8413: Django doesn't reload itself after updating files on disk that raised error
on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: new
Component: Core (Management | Version: SVN
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by aaugustin):

Indeed, Carl is right. Whoever tackles this should review both tickets.

--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:12>

Django

unread,
Aug 30, 2012, 3:30:40 PM8/30/12
to django-...@googlegroups.com
#8413: Django doesn't reload itself after updating files on disk that raised error
on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by ebas):

After reviewing all the patches, i came up with this patch against the
1.4.x branch:
https://github.com/ebas/django/commit/970cee879c84eb495f385822e4e9c99f2aed2088

Its based on a patch found in this post:
https://groups.google.com/forum/?fromgroups=#!topic/django-
developers/rJkUEGdMGV0

The patch consists of the top commits on this branch:
https://github.com/rca/django/commits/master/django/utils/autoreload.py

Just to be complete, the noteworthy other patches from both #9589 and
#8413:
* attachment:autoreload-error_decorator-r11628.patch:ticket:9589
*
https://github.com/buriy/django/commit/7c2c45ed24012d23d0c656c16d53efb8a22846c1#django/utils/autoreload.py

--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:13>

Django

unread,
Oct 9, 2012, 9:24:54 AM10/9/12
to django-...@googlegroups.com
#8413: Django doesn't reload itself after updating files on disk that raised error
on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by tdhutt@…):

This is really annoying. I briefly tested ebas's patch and it seems to
work. Can somebody please apply it?

--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:14>

Django

unread,
Oct 9, 2012, 9:28:34 AM10/9/12
to django-...@googlegroups.com
#8413: Django doesn't reload itself after updating files on disk that raised error
on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by tdhutt@…):

PS: Here is the patch, since apparently github doesn't let you download
them. Tested on django 1.4.1. The relavent file is in (usually) in
/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py so you
can apply it like this:

cd /usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py
sudo patch autoreload.py ~/autoreload_patch.diff

where autoreload_patch.diff contains the following:

53a54
> _error_files = []
57c58
< for filename in filter(lambda v: v, map(lambda m: getattr(m,
"__file__", None), sys.modules.values())):
---
> for filename in filter(lambda v: v, map(lambda m: getattr(m,
"__file__", None), sys.modules.values())) + _error_files:
72a74,76
> try:
> del _error_files[_error_files.index(filename)]
> except ValueError: pass
75a80,92
> def check_errors(fn):
> def wrapper(*args, **kwargs):
> try:
> fn(*args, **kwargs)
> except (ImportError, IndentationError, NameError,
> SyntaxError, TypeError), msg:
> et, ev, tb = sys.exc_info()
> if ev.filename not in _error_files:
> _error_files.append(ev.filename)
>
> raise
> return wrapper
>
144,145c161,162
< reloader(main_func, args, kwargs)
<
---
> wrapped_main_func = check_errors(main_func)
> reloader(wrapped_main_func, args, kwargs)

--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:15>

Django

unread,
Oct 9, 2012, 9:29:45 AM10/9/12
to django-...@googlegroups.com
#8413: Django doesn't reload itself after updating files on disk that raised error
on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by anonymous):

Damnit. Try again:


{{{

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:16>

Django

unread,
Oct 9, 2012, 1:01:02 PM10/9/12
to django-...@googlegroups.com
#8413: Django doesn't reload itself after updating files on disk that raised error
on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by tdhutt@…):

After more extensive testing, it's working quite well but I did get this
one error:

{{{
Unhandled exception in thread started by <function wrapper at 0x1f6e8c0>
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 50,
in apport_excepthook
if not enabled():
TypeError: 'NoneType' object is not callable

Original exception was:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-
packages/django/utils/autoreload.py", line 83, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-
packages/django/core/management/commands/runserver.py", line 111, in
inner_run
ipv6=self.use_ipv6, threading=threading)
File "/usr/local/lib/python2.7/dist-
packages/django/core/servers/basehttp.py", line 253, in run
httpd.serve_forever()
File "/usr/lib/python2.7/SocketServer.py", line 225, in serve_forever
r, w, e = select.select([self], [], [], poll_interval)
AttributeError: 'NoneType' object has no attribute 'select'
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:17>

Django

unread,
Dec 11, 2012, 8:21:07 PM12/11/12
to django-...@googlegroups.com
#8413: Django runserver doesn't reload itself after updating files on disk that

raised error on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix runserver | Patch needs improvement: 1

Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by ramiro):

* keywords: autoreload reload import error fix => autoreload reload import
error fix runserver


--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:18>

Django

unread,
Dec 11, 2012, 10:39:33 PM12/11/12
to django-...@googlegroups.com
#8413: Django runserver doesn't reload itself after updating files on disk that
raised error on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix runserver | Patch needs improvement: 0

Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by ramiro):

* needs_better_patch: 1 => 0


Comment:

I've updated the patch contributed by berto to #9589:
https://github.com/ramiro/django/compare/8413_9589_reload_runserver

Testing of the patch on Unixy platforms (including Mac OS X) is welcome. I
will try to test it on Windows.

I plan to commit this to master in a few days.

--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:19>

Django

unread,
Aug 1, 2013, 8:18:49 AM8/1/13
to django-...@googlegroups.com
#8413: Django runserver doesn't reload itself after updating files on disk that
raised error on import.
-------------------------------------+-------------------------------------
Reporter: buriy | Owner: buriy
Type: Bug | Status: closed

Component: Core (Management | Version: master
commands) | Resolution: duplicate

Severity: Normal | Triage Stage: Accepted
Keywords: autoreload reload | Needs documentation: 0
import error fix runserver | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* status: new => closed
* resolution: => duplicate


Comment:

Closing as duplicate of #9589 - it looks like the fix was committed with a
reference to that ticket but not this one so it wasn't closed
automatically.

--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:20>

Reply all
Reply to author
Forward
0 new messages