Autoreloader and SimplePlugin

12 views
Skip to first unread message

smetj

unread,
Dec 11, 2009, 7:59:56 PM12/11/09
to cherrypy-users
Hi List,

When Cherrypy autoreloads because I have changed and saved the script
it keeps hanging in the loop defined at simple_test.
I though the stop method was called on simple_test when autoreloader
kicks in, but this isn't the case..
Why is that and how can I make autoreloader work as it should with
such a loop.
Here's a simplified example of my original code:

#!/usr/bin/python

import cherrypy, time
from cherrypy.process import plugins, servers

class simple_test(plugins.SimplePlugin):
def __init__(self, bus):
plugins.SimplePlugin.__init__(self, bus)
def start(self):
self.looper=True
self.bus.log("Starting the simple_test thread.")
while self.looper:
self.bus.log("Looping in the simple_test thread.")
time.sleep(5)
def stop(self):
self.looper=False
self.bus.log("Stopping the configfile monitor thread.")
self.bus.exit()

class Server:
def __init__(self):
cherrypy.engine.simple_test=simple_test(cherrypy.engine)
pass
def start(self):
cherrypy.engine.start()
cherrypy.engine.simple_test.start()
cherrypy.engine.block()
def stop(self):
cherrypy.engine.stop()

if __name__ == '__main__':
teleporter=Server()
teleporter.start()


Thanks for the help.

Smetj
Reply all
Reply to author
Forward
0 new messages