Commit Graph

113 Commits

Author SHA1 Message Date
Aymeric Augustin b79fc11d73 Made the autoreloader survive all exceptions.
Refs #24704.
2015-08-29 20:50:00 +02:00
Aymeric Augustin fe6ddb837d Fixed #24704 -- Made the autoreloader survive SyntaxErrors.
With this change, it's expected to survive anything except errors
that make it impossible to import the settings. It's too complex
to fallback to a sensible behavior with a broken settings module.

Harcoding things about runserver in ManagementUtility.execute is
atrocious but it's the only way out of the chicken'n'egg problem:
the current implementation of the autoreloader primarily watches
imported Python modules -- and then a few other things that were
bolted on top of this design -- but we want it to kick in even if
the project contains import-time errors and django.setup() fails.

At some point we should throw away this code and replace it by an
off-the-shelf autoreloader that watches the working directory and
re-runs `django-admin runserver` whenever something changes.
2015-08-29 20:49:56 +02:00
Aymeric Augustin c2fcba2ac7 Ensured gen_filenames() yields native strings.
This also fixes a test failure on Python 2 when Django is installed in a
non-ASCII path. This problem cannot happen on Python 3.
2015-08-29 20:49:25 +02:00
Aymeric Augustin 23620cb8e0 Accounted for error files in the autoreloader.
* When some old files contain errors, the second call to
  gen_filenames() should return them.
* When some new files contain errors, the first call to
  gen_filenames(only_new=True) should return them.
2015-08-29 20:47:38 +02:00
Chris Bainbridge e5cfa394d7 Refs #23882 -- Added detection for moved files when using inotify polling
Commit 15f82c7 ("used pyinotify as change detection system when
available") introduced a regression where editing a file in vim with
default settings (writebackup=auto) no longer causes the dev server
to be restarted. On a write, vim moves the monitored file to a backup
path and then creates a new file in the original. The new file is not
monitored as it has a different inode. Fixed this by also watching for
inotify events IN_DELETE_SELF and IN_MOVE_SELF.
2015-07-07 12:23:04 -04:00
Tim Graham 2ee9bce654 Removed some obsolete absolute_imports. 2015-02-09 13:37:23 -05:00
Tim Graham 0ed7d15563 Sorted imports with isort; refs #23860. 2015-02-06 08:16:28 -05:00
Tim Graham 18f3e79b13 Removed threading fallback imports.
Django imports threading in many other places without fallback.
2015-01-28 10:23:25 -05:00
Tim Graham b8cb5ba708 Fixed #23083 -- Fixed runserver reloading when deleting a file.
Thanks Collin Anderson for the report and hirokiky for the fix.
2014-07-25 13:23:52 -04:00
Claude Paroz 4e424084e6 Fixed #22991 -- Prevented *.pyc files in autoreload monitoring
This fixes a regression introduced in 6d302f639.
Thanks lorinkoz at gmail.com for the report, Collin Anderson
for the initial patch and Simon Charette for the review.
2014-07-15 09:57:54 +02:00
Tim Graham fddd95254e Fixed flake8 errors. 2014-07-07 19:12:39 -04:00
Claude Paroz 6d302f6396 Fixed pyinotify performance regression in 15f82c7011
Refs #9722. Thanks Tim Graham for the review.
2014-07-06 21:41:02 +02:00
Tim Graham 5e9773269a Added newline to fix flake8 error. 2014-06-26 15:16:23 -04:00
Claude Paroz 0d363b25b8 Fixed #22857 -- Reset translations when only .mo file changed
No need to restart the server when a translation file changes.
Refs #9523. Thanks artscoop for the report and Tim Graham for
the review.
2014-06-26 10:01:52 +02:00
Alex Gaynor 608e6eb295 Added an explanatory comment. Refs #22017 2014-04-02 09:47:18 -07:00
Alex Gaynor 666990a2a0 Revert "Merge pull request #2508 from tomwys/patch-1"
This reverts commit c45607e939, reversing
changes made to 9769337ca8.
2014-04-02 09:45:42 -07:00
Tomasz Wysocki 6eb891f57a Don't copy list for iteration. 2014-04-02 17:28:09 +02:00
Claude Paroz e0381cdf2e Fixed #22017 -- Prevented RuntimeError on Python 3
Refs #21049. Thanks quinox for the report.
2014-02-12 10:26:08 +01:00
Aymeric Augustin 1716b7ce5a Renamed AppCache to Apps.
Also renamed app_cache to apps and "app cache" to "app registry".

Deprecated AppCache.app_cache_ready() in favor of Apps.ready().
2013-12-24 12:25:17 +01:00
Aymeric Augustin 2fef9e5375 Moved apps back in the toplevel django namespace.
Reverted 4a56a93cc4.
2013-12-22 11:39:55 +01:00
Aymeric Augustin 65cd74be8e Stopped iterating on INSTALLED_APPS.
Used the app cache's get_app_configs() method instead.
2013-12-22 11:39:18 +01:00
Aymeric Augustin 3beffea4b0 Fixed #21621 -- Removed kqueue autoreloader. 2013-12-15 14:43:52 +01:00
Aymeric Augustin 4d738fcc3b Fixed #21546 -- Strengthened kqueue detection.
Thanks Loic Bistuer.
2013-12-04 10:11:42 +01:00
Loic Bistuer 9ccde8cfaf Fixed #21545 -- autoreload kqueue events weren't cleared which caused an infinite loop. 2013-12-03 00:12:04 +07:00
Baptiste Mispelon e681b2861d Fixed #21500 -- Removed imports of deprecated utils.importlib 2013-11-24 16:45:01 +01:00
Alex Gaynor bc742ca110 Flake8 fixes -- including not runnign flake8 over a backported file 2013-11-11 14:05:14 -08:00
Aymeric Augustin f67cce0434 Fixed #21420 once more. 2013-11-11 15:48:48 +01:00
Bouke Haarsma 2397daab4a Fixed #9523 -- Restart runserver after compiling apps translations
Django also uses locales provided by apps, which also might change. Also when
i18n is disabled, there is no need for watching translation files.
2013-11-11 11:43:09 +01:00
Aymeric Augustin dbbd10e75f Fixed #21420 -- Autoreloader on BSD with Python 3.
Thanks Bouke Haarsma for the report.
2013-11-11 10:46:24 +01:00
Alex Gaynor 8a0489221e Flake8 fixes 2013-11-05 09:17:50 -08:00
Aymeric Augustin 37a2e70cec Updated the set of watched files after each request.
Otherwise the kqueue-based autoreloader may not see changes to files
that weren't imported when the server started.

Thanks Bouke Haarsma for the report and Loïc Bistuer for locating the
problem.
2013-11-04 22:37:36 +01:00
Ray Ashman Jr e2ae8b048e Correct flake8 E302 violations 2013-11-02 19:53:29 -04:00
Alex Gaynor 7548aa8ffd More attacking E302 violators 2013-11-02 13:12:09 -07:00
Alex Gaynor ee48f4af99 Merge pull request #1848 from rayashmanjr/master
Correct flake8 violation E261
2013-11-02 12:34:34 -07:00
Ray Ashman Jr dcfc8fa972 Correct flake8 violation E261 2013-11-02 15:27:47 -04:00
Tim Graham 36ded01527 Fixed #21302 -- Fixed unused imports and import *. 2013-11-02 15:24:56 -04:00
Bouke Haarsma c3936c0d79 Fixed #9523 -- Restart runserver after translation MO files change
Thanks to Krzysztof Kulewski for the initial patch.
2013-11-02 10:29:07 +01:00
Aymeric Augustin 2bba0d275b Improved resource limits handling in the kqueue autoreloader.
Refs #21356. Thanks Loïc.
2013-11-01 10:31:01 +01:00
Aymeric Augustin 47217f2f29 Reduce the set of events that trigger a reload.
This seems to avoid multiple reloads.
2013-10-31 10:15:42 +01:00
Aymeric Augustin 8f09ec61f8 Add instant autoreload on platforms supporting kqueue. 2013-10-30 23:08:12 +01:00
Unai Zalakain 15f82c7011 Fixed #9722 - used pyinotify as change detection system when available
Used pyinotify (when available) to replace the "pool-every-one-second"
mechanism in `django.utils.autoreload`.

Thanks Chris Lamb and Pascal Hartig for work on the patch.
2013-10-30 11:45:43 -04:00
Tim Graham b67ab75e82 Fixed assorted flake8 errors. 2013-10-11 07:25:14 -04:00
Tim Graham 1dae4ac177 Whitespace cleanup.
* Removed trailing whitespace.
* Added newline to EOF if missing.
* Removed blank lines at EOF.
* Removed some stray tabs.
2013-10-10 16:49:20 -04:00
Max Burstein 559cb826b8 Fixed #21049 -- Fixed autoreload for Python 3
Changed th system module values check to return a list.
In Python 3 it returns a dict_view which could occassionally produce
a runtime error of "dictionary changed size during iteration".
2013-09-06 14:37:43 -05:00
Thomas Bartelmess f9a46d7bc9 Made dev server autoreloader ignore filenames reported as None.
Useful under Jython. Thanks Thomas Bartelmess for the report and patch.

Ref #9589.
2013-01-11 15:31:39 -03:00
Aymeric Augustin bbabfdccce Fixed #19485 -- Python 3 compatibility for c2a6b2a4.
Refs #9589.
2012-12-17 09:46:26 +01:00
Ramiro Morales c2a6b2a43f Fixed #9589 -- Made development web server more robust in the presence of a wider variety of code errors.
Thanks goes to contributor with Trac user 'berto' for the patch.
2012-12-15 10:17:25 -03:00
Aymeric Augustin 4c1286cf78 [py3] Added compatibility import of thread/_thread
This commit fixes the auto-reload of the development server.

I should have done that change in ca07fda2.
2012-08-18 10:56:56 +02:00
Aymeric Augustin 0c198b85a3 [py3] Replace filter/lambda by list comprehensions
This is more idiomatic and avoids returning a list on Python 2 and
an iterator on Python 3.
2012-08-14 14:31:06 +02:00
Aymeric Augustin ca07fda2ef [py3] Switched to Python 3-compatible imports.
xrange/range will be dealt with in a separate commit due to the huge
number of changes.
2012-07-22 09:29:56 +02:00
Aymeric Augustin baf63f6e57 Fixed #10725 -- When the child process spawned by the autoreloader gets killed by a signal, passed the signal to the parent, in order to make debugging easier.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17296 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-12-30 14:12:31 +00:00
Jannis Leidel d37e3baf62 Fixed #16523 -- Made path handling in autoreload code work on Jython. Thanks, Aymeric Augustin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16619 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-08-15 08:29:08 +00:00
Karen Tracey acbb911ad5 Fix #15880: Prevent "stalling" when running dev server in background by ignoring SIGTTOU for the duration of tcsetattr.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16326 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-06-04 15:29:11 +00:00
Karen Tracey 3e7ce3c750 Ensure stdin is a tty before handing it to termios, so as to prevent prolems when running under IDEs.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15911 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-03-24 12:36:33 +00:00
Karen Tracey f5b22ed997 Fixed #15565: Ensure terminal echo is on after reloader reloads (something turns it off on some systems if reload happens while at a pdb prompt). Thanks for the report zimnyx.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15883 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-03-19 22:09:38 +00:00
Russell Keith-Magee 3a9e2e90ac Fixed #13062 -- Ensure that runserver exposes all warnings requested at the command line. Thanks to gremmie for the report, and claudep for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15233 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-01-17 13:15:08 +00:00
Malcolm Tredinnick be4390f834 Made auto-reloading for the dev server a little more friendly in the Jython
case. Patch from Leo Soto. Fixed #8147.

In passing, also corrected a typo when reloading .pyo files. Fixed #8157.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8235 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-08 17:54:35 +00:00
Adrian Holovaty 1bf811e28d Fixed #2330 -- Added hack to stop KeyErrors from being thrown by the autoreloading development server if USE_I18N=False
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3482 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2006-07-28 22:13:34 +00:00
Adrian Holovaty 8623bd126d Fixed #2036 -- autoreload.py no longer fails for uninstalled 'thread' module. Thanks, plmeister@gmail.com
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3020 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2006-05-31 14:53:23 +00:00
Adrian Holovaty 551897b134 Fixed #937 -- autoreload no longer reloads on every request on Windows. Thanks for the patch, Eugene
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1686 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2005-12-16 04:59:35 +00:00
Adrian Holovaty 3ad82eff77 Improved autoreloader to ignore files that might be in eggs. Refs #596
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1010 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2005-10-25 02:01:10 +00:00
Adrian Holovaty e1d21e5bcf Added copyright notice to utils/autoreload for CherryPy folks
git-svn-id: http://code.djangoproject.com/svn/django/trunk@267 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2005-07-21 04:10:47 +00:00
Adrian Holovaty 9566a61a22 Added auto-reload to standalone server! Fixes #113. Thanks very much to Jason Huggins for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@266 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2005-07-21 04:08:54 +00:00