Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #445 (defect)

Opened 3 years ago

Last modified 2 years ago

autoreload.py mistakenly reloads when Kid inserts '<string>' into sys.modules

Status: closed (fixed)

Reported by: scott@spamcop.net Assigned to: rdelon
Priority: normal Milestone:
Component: CherryPy code Keywords: autoreload developer
Cc:

The autoreload code attempts to call stat on a "file" called "<string>" and fails causing the server to reload after every request. This behaviour was seen with Python 2.4.2 on WinXP. The simplest fix would be to add an additional condition on the current test for the None object.

from:

if filename:

to

if filename and filename[0] <> '<':

Change History

03/03/06 18:47:26: Modified by fumanchu

  • status changed from new to closed.
  • resolution set to worksforme.

Can you supply an example of when this occurs? I can't seem to reproduce it.

06/26/06 09:34:53: Modified by miles.thibault@gmail.com

  • status changed from closed to reopened.
  • resolution deleted.
  • severity changed from major to normal.
  • summary changed from autoreload.py is confused by a module named <string> to autoreload.py mistakenly reloads when Kid inserts '<string>' into sys.modules.

This happens while using Kid:

from kid import Template
Template(source='<div />')

When Kid loads a file-based template, it creates a .pyc file and inserts the file name into sys.modules. When Kid loads a template from a string, it does not produce a file, but it does insert '<string>' into sys.modules.

CherryPy's autoreloader finds '<string>' in sys.modules, but doesn't find a corresponding <string>.py file, so it reloads.

One solution would be to make sure a file exists on the file system (as mentioned in #518). The problem is that if you intentionally remove a file, you'd like the autoreloader to fire.

Another solution would be to ignore any file named '<string>' (this is what I'm currently doing). While it's not that nice, I think Kid and CherrryPy are used together often enough to justify it.

A third solution would be to specify a list of files that the autoreloader should ignore. The list could default to ['<string>'], as this is a fairly obscure problem.

09/02/06 04:01:56: Modified by fumanchu

  • status changed from reopened to closed.
  • resolution set to fixed.

Fixed for CP 2.2 in [1315]. This should already be fixed in CP 3 with the 'oldtime' check inside Engine.autoreload.

Hosted by WebFaction

Log in as guest/cpguest to create tickets