#22857 closed New feature (fixed)
Django 1.7 runserver auto-reload : setting behaviour by extensions
Reported by: | artscoop | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.7-beta-2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
I am experiencing a problem introduced by Django 1.7b2 in django-rosetta (app for editing locale files).
In Django 1.6, in a development server, rosetta responded to a button click, updated .po files and redirected to the same page.
In Django 1.7, still in a development server, rosetta responds to a button click, updates .po files and the server is immediately killed and restarted (connection closed). This is an unwanted behaviour and I have no control over this.
Is there a way to tell runserver's autoreload mechanism to ignore locale files, or file extensions ?
Running runserver with the --noreload flag is not really an option.
Change History (18)
comment:1 by , 11 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 11 years ago
In my opinion, the request in #9523 was a very valid one and still is... but yes, some django apps help with editing translations. This is one category of apps that defeats the purpose of autoreloading on .mo changes. :(
comment:3 by , 11 years ago
Not entirely sure this is a release blocker, though - it'd be nice to fix, but at the same time I don't think it's a regression from previously documented behaviour, just a pattern that happened to work.
Said app could, for example, use an ajax request to kick off the rebuild and then poll the server to see when it reappears before reloading.
(Not saying we shouldn't land a fix for this in 1.7, just saying that I'm not really prepared to hold the entire release up for it...)
comment:5 by , 11 years ago
I am not sure if it will, but it currently has some issues and even if we resolve them, I'm not sure backporting to 1.7 this late in the release cycle is acceptable. Currently the "best" solution I am thinking of is adding a --noreload-translations
flag to runserver
. Open to other opinions and ideas!
comment:6 by , 11 years ago
Another idea (completely untested) would be to gather mo files in another set of files in runserver and only reset translations when one of these files changes instead of restarting the server.
comment:7 by , 11 years ago
@claudep I didn't know it was possible to reset/reload translations separately (even though it makes perfect sense), but I think it's better than the --noreload-translations, because the command option would have to be officially documented, and maybe deprecated very quickly.
The suggestion about AJAXing a view until the server comes back is good but a bit hacky.
I do think resetting translation cache on .mo change is the best idea, and would be more immediate than reloading the whole dev server (which ideally should be reloaded on code changes only). It seems that resetting the translation is a simple as in this example: https://djangosnippets.org/snippets/1704/
comment:8 by , 11 years ago
If we can reset the translation cache then let's try that, but I'm really pushed to define this as a release blocker (it is not breaking any part of Django directly, and the behaviour it produces can be worked around with --noreload
if you need to file translations), so if we get down to the release time and this is what's left... it might not make it.
comment:9 by , 11 years ago
Severity: | Release blocker → Normal |
---|
I agree that this change of behaviour is annoying for rosetta but I don't think we should delay 1.7 for this edge case.
comment:11 by , 11 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Patch seems okay to me, although I'm not really familiar with this stuff so a second pair of eyes wouldn't hurt.
comment:14 by , 11 years ago
@claudep Works flawlessly. Could not test on the master branch since it breaks many third party apps, but copied the autoreload.py file into the working 1.7b4. the server did not restart on .mo file changes, yet the new translation was properly taken into account. Of course it restarted properly on .py code changes.
comment:15 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:16 by , 10 years ago
@artscoop Thanks for the feedback!
I won't make alone the decision to backport to 1.7. If other core devs think it's a good idea, just speak.
comment:17 by , 10 years ago
I would backport this or revert #9523 from 1.7 so we don't ship a buggy change.
I guess this is #9523. One user's feature is another user's bug... I guess it's likely possible to add a flag to control the behavior although I'm not sure it's ideal to be adding more flags like that to
runserver
.