|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Daemonizing and my pluginI have a cherrypy application that, in addition to the normal work, needs to respond to UDP broadcasts. The UDP server is implemented in a SimplePlugin subclass. The plugin's start() method starts a thread. However, this doesn't work correctly when the application is daemonized. It looks like the thread is started before the forking occurs. Here's the logfile (the timestamps are wrong because this is running on an embedded system that has no hardware clock): [01/Jan/1970:01:03:49] ENGINE Listening for SIGHUP. [01/Jan/1970:01:03:49] ENGINE Listening for SIGTERM. [01/Jan/1970:01:03:49] ENGINE Listening for SIGUSR1. [01/Jan/1970:01:03:49] ENGINE Bus STARTING [01/Jan/1970:01:03:49] ENGINE There are [<_MainThread(MainThread, started 1073872192)>, <Thread(Thread-1, started daemon 1087337616)>] active threads. Daemonizing now may cause strange failures. [01/Jan/1970:01:03:49] ENGINE Forking once. [01/Jan/1970:01:03:49] ENGINE Forking twice. [01/Jan/1970:01:03:49] ENGINE Daemonized to PID: 844 [01/Jan/1970:01:03:49] ENGINE PID 844 written to '/var/run/hvampd.pid'. [01/Jan/1970:01:03:49] ENGINE Started monitor thread '_TimeoutMonitor'. [01/Jan/1970:01:03:49] ENGINE Serving on 0.0.0.0:8080 [01/Jan/1970:01:03:49] ENGINE Bus STARTED Any ideas how this can be solved? -- Thanks, Thomas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cherrypy-users" group. To post to this group, send email to cherrypy-users@... To unsubscribe from this group, send email to cherrypy-users+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Daemonizing and my pluginThomas Heller wrote: > I have a cherrypy application that, in addition to the > normal work, needs to respond to UDP broadcasts. > > The UDP server is implemented in a SimplePlugin subclass. > The plugin's start() method starts a thread. I hope the plugin's stop() method stops that thread for your continued Ctrl-C sanity. ;) > However, this doesn't work correctly when the application > is daemonized. It looks like the thread is started before > the forking occurs. Here's the logfile (the timestamps > are wrong because this is running on an embedded system > that has no hardware clock): > > [01/Jan/1970:01:03:49] ENGINE Listening for SIGHUP. > [01/Jan/1970:01:03:49] ENGINE Listening for SIGTERM. > [01/Jan/1970:01:03:49] ENGINE Listening for SIGUSR1. > [01/Jan/1970:01:03:49] ENGINE Bus STARTING > [01/Jan/1970:01:03:49] ENGINE There are [<_MainThread(MainThread, > started 1073872192)>, <Thread(Thread-1, started daemon 1087337616)>] > active threads. Daemonizing now may cause strange failures. > [01/Jan/1970:01:03:49] ENGINE Forking once. > [01/Jan/1970:01:03:49] ENGINE Forking twice. > [01/Jan/1970:01:03:49] ENGINE Daemonized to PID: 844 > [01/Jan/1970:01:03:49] ENGINE PID 844 written to > [01/Jan/1970:01:03:49] ENGINE Started monitor thread '_TimeoutMonitor'. > [01/Jan/1970:01:03:49] ENGINE Serving on 0.0.0.0:8080 > [01/Jan/1970:01:03:49] ENGINE Bus STARTED > > > Any ideas how this can be solved? Yup, cherrypy.process.plugins.Daemonizer.start.priority = 65. Just set a priority on your start method that's higher than that so it runs after Daemonizer.start; for example: def start(self): start_my_udp_server() start.priority = 80 Priorities of other builtin start listeners: default 50 Daemonizer.start 65 ThreadMonitor 70 Autoreload 70 PIDFile 70 cherrypy.server 75 DropPrivileges 77 ...you can override any of these at your leisure (and at your own risk--the "strange failures" message you received, for example, is there for a good reason; see the source code for further comments about default priorities). Robert Brewer fumanchu@... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cherrypy-users" group. To post to this group, send email to cherrypy-users@... To unsubscribe from this group, send email to cherrypy-users+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |