* 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.
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>
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>
Comment (by aaugustin):
Indeed, Carl is right. Whoever tackles this should review both tickets.
--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:12>
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>
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>
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>
Comment (by anonymous):
Damnit. Try again:
{{{
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:16>
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>
* keywords: autoreload reload import error fix => autoreload reload import
error fix runserver
--
Ticket URL: <https://code.djangoproject.com/ticket/8413#comment:18>
* 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>
* 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>