Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#22991 closed Bug (fixed)

Development server not reloading with *.pyc files and without inotify

Reported by: lorinkoz@… Owned by: nobody
Component: Core (Management commands) Version: 1.7-rc-1
Severity: Release blocker Keywords:
Cc: anubhav9042@…, cmawebsite@…, melinath Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm on Windows, not sure when this started to happen but the development server is not restarting/reloading anymore when I change code in models.py. I'm not using pynotify.

Change History (14)

comment:1 Changed 12 months ago by timo

  • Cc anubhav9042@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Development server reloading to Development server not reloading on Windows
  • Type changed from Uncategorized to Bug

Anubhav, can you reproduce this? If so, could you bisect the regression?

comment:2 Changed 12 months ago by timo

#23020 reports the same issue on Mac OS X, but I have no problems on Linux.

comment:3 Changed 12 months ago by CollinAnderson

I can confirm it doesn't work and bisected it to 1bb8ccdb9e70bee35759f2ada4d661481852ab95 (Fixed pyinotify performance regression)

comment:4 Changed 12 months ago by timo

  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 12 months ago by CollinAnderson

  • Summary changed from Development server not reloading on Windows to Development server not reloading with *.pyc files and without inotify

Ok, I can reproduce it on Ubuntu 12.04 by uninstalling python-inotify (pyinotify) and turning off sys.dont_write_bytecode (PYTHONDONTWRITEBYTECODE). It's happening on all platforms, so I'll mark #23020 as a duplicate.

comment:6 Changed 12 months ago by CollinAnderson

  • Needs tests set

*.pyc filenames are ending up in _cached_filenames, and then being returned from the cache without being converted from .pyc to .py. This change caches the *.py filenames instead.
https://github.com/django/django/pull/2913

I also noticed an inconsistency with _error_files. It's not clear if or when those should be added to _cached_filenames and if and when inotify needs to start watching them.

I would appreciate someone else writing a test case.

comment:7 Changed 12 months ago by CollinAnderson

  • Has patch set

comment:8 Changed 12 months ago by CollinAnderson

  • Cc cmawebsite@… added

comment:9 Changed 12 months ago by CollinAnderson

_error_files handles cases from #9589 and #8413. I bet those have also regressed.

comment:10 Changed 12 months ago by melinath

  • Cc melinath added

comment:11 Changed 12 months ago by CollinAnderson

I actually can't reproduce any _error_files issues. It seems that nowadays, either the framework fully stops the process on models.py and admin.py errors before the autoreloader starts (would be nice to fix someday), or in other files, like views.py, it can handle re-importing the bad files without needing to reload.

Last edited 12 months ago by CollinAnderson (previous) (diff)

comment:12 Changed 12 months ago by claudep

  • Needs tests unset

I've slightly adapted the PR from Collin and added a one-line test in https://github.com/django/django/pull/2918

comment:13 Changed 12 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 4e424084e6d796f7ed5f215330cd0b98287c1300:

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.

comment:14 Changed 12 months ago by Claude Paroz <claude@…>

In f2011e21a2d803ab6328852c3af4a4bf6701b11d:

[1.7.x] 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.
Backport of 4e424084e from master.

Note: See TracTickets for help on using tickets.
Back to Top