Python, CherryPy, Windows Service, and BackgroundTask - Tasks not recurring as expected -


i trying series of python scripts update every 60 seconds , serve json via cherrypy on windows (for wmi capabilities) , managed windows service. in short, if run code in console outside service, tasks execute backgroundtask class regularly , without problems. once wrapped in cherrypy windows service, execute once or twice, , stop working after (the json stops changing).

this cherrypy 3.3.0 on activestate python 2.7 (community).

running code below, script works (import snmp python script run every 60 seconds, in form).

import cherrypy cherrypy.lib.static import serve_file import cherrypy.process.plugins import win32serviceutil import win32service import win32event import os import snmp  class myserver():     @cherrypy.expose     def snmp_ajax(self):         cherrypy.response.headers['content-type'] = 'application/json'         return snmp.json  def snmp_callback():     global snmp_data     snmp.generate_json(snmp_data)  snmp_data = cherrypy.process.plugins.backgroundtask (60, snmp_callback) snmp_data.start()  cherrypy.tree.mount(myserver(), '/', config=config) cherrypy.config.update({         'global':{             'server.socket_host': '0.0.0.0',             'server.socket_port': 8989,         'log.screen': false,             'engine.autoreload.on': false,             'engine.sighup': none,             'engine.sigterm': none         }                     })   cherrypy.engine.start() 

now, run windows service, bottom cherrypy code put inside cherrypyservice class follows:

class cherrypyservice(win32serviceutil.serviceframework):     """nt service."""      _svc_name_ = "myservice"     _svc_display_name_ = "my service"      def svcdorun(self):         cherrypy.tree.mount(myserver(), '/', config=config)                  cherrypy.config.update({                 'global':{                     'server.socket_host': '0.0.0.0',                     'server.socket_port': 8989,                     'log.screen': false,                     'engine.autoreload.on': false,                     'engine.sighup': none,                     'engine.sigterm': none                 }                             })          cherrypy.engine.start()          cherrypy.engine.block()      def svcstop(self):         self.reportservicestatus(win32service.service_stop_pending)         cherrypy.engine.exit()          self.reportservicestatus(win32service.service_stopped)  if __name__ == '__main__':     win32serviceutil.handlecommandline(cherrypyservice) 

however, once it's wrapped in cherrypyservice class, backgroundtask seems stop working, sticks on last query , stops updating no logic behind it. after 1 run, after three, never reaches 5 runs.

any suggestions appreciated.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -