|
List Info
Thread: how to create a new non-cherrypy process/thread from within cherrypy?
|
|
| how to create a new non-cherrypy
process/thread from within cherrypy? |

|
2006-05-21 20:28:47 |
|
Hi I'm running a TG app and I'm trying to create a second flow of execution (right now I'm just using a thread)
this code is in my main controller which is the one being call by TG at the start.
def runTurBot():
turbot=TurBot() log.info("starting TurBot") #we must take care of the thread, because ircbot wont do it for us. turbot.start()
from threading import Thread Thread(target=runTurBot).start()
The problem is that somehow 2 threads are created, I'm not sure if this is related to the autoreload function of TG or something to do with cherrypy itself. And I believe there is a way I don't know of doing this with cherrypy.
the main loop of my app (which i can not change) is as follows. This is what ends up being call in the turbot.start method def process_forever(self, timeout=0.2): while 1: self.process_once
(timeout)
def process_once(self, timeout=0): sockets = map(lambda x: x._get_socket(), self.connections) sockets = filter(lambda x: x != None, sockets) if sockets: (i, o, e) =
select.select(sockets, [], [], timeout) self.process_data(i) else: time.sleep(timeout) self.process_timeout()
so as you can see this is not "thread friendly" but I actually dont need my TG app be aware of the actions of this thread, since they will comunicate thru the DB
this is with * TurboGears 0.9a6 * nose 0.8.7.2 * ConfigObj 4.3.1 * RuleDispatch 0.5a0.dev-r2115 * setuptools 0.6a11 * FormEncode 0.5.1 * cElementTree 1.0.5-20051216
* PasteScript 0.5.1 * elementtree 1.2.6 * simplejson 1.3 * SQLObject 0.7.1dev-r1457 * CherryPy 2.2.1 * TurboKid 0.9.5 * TurboCheetah 0.9.5 * TurboJson 0.9.2 * PyProtocols 1.0a0 * Cheetah 1.0
* PasteDeploy 0.5 * Paste 0.5 * FormEncode 0.5.1 * kid 0.9.1 * Cheetah 1.0 * elementtree 1.2.6
--~--~---------~--~----~------------~-------~--~----~
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 googlegroups.com To unsubscribe from this group, send email to cherrypy-users-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/cherrypy-users -~----------~----~----~----~------~----~------~--~---
|
[1]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|