title: Is there a way for BaseRequestHandler classes to be stateful?
body: <p><strong>Short Question</strong><br>
  Using my examples below, is there a Pythonic way to share <code>my_object</code>'s actual instance with with the BaseRequestHandler class?  </p>
  
  <p><strong>Background</strong><br>
  By definition, the BaseRequestHandler class creates a new instance for each request.  Because of this, I am struggling to try find a solution on how to get data from the <code>handle()</code> function back to the <code>ProtocolInterface</code> instance.  Note that this might be the wrong approach if I am needing to do something in <code>handle()</code> other than print to stdout.  </p>
  
  <p>At this point in time, I do not believe that global variables will work because <code>my_object</code> is passed in and is expected to change often (this is why <code>handle()</code> needs to see it.  To see an example client (sending bogus data) see my <a href="https://stackoverflow.com/q/8546870/157744">other SO question</a>.  I think the biggest issue I am facing is the the socketservers are running in a background thread.  </p>
  
  <p><strong>Example of what I would like to do</strong>  </p>
  
  <pre><code>class ProtocolHandler(SocketServer.BaseRequestHandler):
      def handle(self):
          while(1):
              self.data = self.request.recv(1024)
              if self.data == '':
                  break
              self.request.send("Success") 
              self.my_object.success = True#  &lt;--- How can I share my_object's instance?
  
  class ProtocolInterface():
      def __init__(self, obj, host='127.0.0.1', port=8000, single_connection=False):
          self.my_object = obj # &lt;--- This ideally is the same instance seen in ProtocolHandler
          self.host = host
          self.port = port
  
          # Create the socket server to process in coming traffic
          if(single_connection):
              self.server = SocketServer.TCPServer((self.host, self.port), ProtocolHandler)
          else:
              self.server = SocketServer.ThreadingTCPServer((self.host, self.port), ProtocolHandler)
  
      def start(self):
          print "Server Starting on HOST: " + self.host
          server_thread = threading.Thread(target=self.server.serve_forever)
          server_thread.daemon = True
          server_thread.start()
  </code></pre>