Indeed -- though the current version of code doesn't handle that
either. That line was copied from the current Reloader class.

You probably shouldn't be running optimized versions while debugging
anyway -- it turns off asserts which can be useful for tracking down
issues. Also assert is used in a couple of places in webpy
programatically -- see nthstr and _EmailMessage for a couple examples.

On Feb 12, 3:01 am, andrei <[email protected]> wrote:
> Justin,
>
> I would add, that you check only for "pyc" extension.
>
> In my apache2+mod_wsgi configuration I use "WSGIPythonOptimize 2"
> directive, that creates files with "pyo" extension.
>
> On Feb 11, 10:30 am, Justin Davis <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hey everyone,
>
> > I modified the webpy reloader to be less kind in general -- syntax
> > errors, for instance, will just kill the process -- but it generally
> > gets rid of issues with reloader not picking up changes. It only works
> > in linux, by waking up every second to check for changes. If anyone's
> > interested, here's the code and how to use it:
>
> > app = web.application(urls, globals() # as usual
>
> > ## Reloader
> > import sys, os, signal, pprint, types
> > class PeriodicReloader(object):
> >     def __init__(self, interval=1):
> >         self.interval = interval
> >         self.mtimes = {}
> >         self.sig_setup()
>
> >     def sig_setup(self):
> >         signal.signal(signal.SIGALRM, self.check)
> >         signal.alarm(self.interval)
>
> >     def check(self, signum, frame):
> >         for mod in sys.modules.values():
> >             if not isinstance(mod, types.ModuleType):
> >                 continue
>
> >             path = getattr(mod, '__file__', None)
> >             if not path:
> >                 continue
>
> >             mtime = os.stat(mod.__file__).st_mtime
> >             if mod.__file__.endswith('.pyc') and
> > os.path.exists(mod.__file__[:-1]):
> >                 mtime = max(os.stat(mod.__file__[:-1]).st_mtime,
> > mtime)
>
> >             if mod not in self.mtimes:
> >                 self.mtimes[mod] = mtime
> >             elif self.mtimes[mod] < mtime:
> >                 web.debug("Reloading app due to module change")
> >                 os.execv(sys.executable, [sys.executable] + sys.argv)
> >         self.sig_setup()
>
> > ### Go ###
> > if __name__ == '__main__':
> >     if web.config.debug:
> >         PeriodicReloader()
> >     app.run()

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to