Felix Schwarz schrieb:
I have a TG app with multiple threads. Now I have to do some initialization
for every thread. I don't want to clutter all my controller functions checking if this thread is initialized or not (besides that would be quite an overhead I guess).

For now I ended up with a monkey patch. This is called before
    cherrypy.server.start(server=...)
(I'm building my own WSGI stack with CherryPy's CherryPyWSGIServer)

def monkey_patch_cherrypy_threads():
    from cherrypy._cpwsgiserver import WorkerThread
    class FakeThread(WorkerThread):
        def run(self):
            # do your initialization stuff here
            WorkerThread.run(self)
    cherrypy._cpwsgiserver.WorkerThread = FakeThread

If there are official hooks which can be used, don't hesitate to tell me. :-)

fs

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to