I'm implementing a python application which is using ThreadingTCPServer and a custom subclass of BaseRequestHandler. The problem with this is that the ThreadingTCPServer seems to automatically spawn threads and create instances of the handler, calling their handle() function. However this leaves me with no way to pass data to the handler other than using global variables or class variables, both of which seem hackish. Is there any better way to do it?

Ideally this should be something like:

class ThreadedTCPServer(ThreadingTCPServer):
    def process_request(self, *args, **kwargs):
        ThreadingTCPServer.process_request(self, data, *args, **kwargs)

with the handler like

class ThreadedTCPRequestHandler(BaseRequestHandler):
    def handle(self,data):
        #do something with data
Edit
Report