title: Python : _MainThread' object has no attribute '_state'
body: <p>Hey Guys I am creating an application which takes in a request from the user. The main class in the server side is the Controller . I spawn a thread during init, which keeps actively listening for requests from the client ( I need to spawn a thread here. )</p>
  
  <p>Once I get an request, I look into the type of request and call a function to handle it.</p>
  
  <p>In that function, I want to create multiple processes to utilise my 8 cores effectively.</p>
  
  <p>Here is the code:-</p>
  
  <pre><code>class Controller(app_manager.RyuApp):
      OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
  
      def __init__(self, *args, **kwargs):
          self.datapaths={}
          self.monitor_thread=hub.spawn(self._monitor)
          super(Controller, self).__init__( *args, **kwargs)
  
      def _monitor(self):
          global connstream   
          while True:
              #Get Connection from client
  
              data = connstream.read(15000)
              data=eval(data)
              print "Recieved a request from the client:-",data
              for key,value in data.iteritems():
                  type=int(key)
                  request=value
                  if type==4:
                      self.get_route(type,request,connstream)
  
  
      def get_route(self,type,request,connection):
              global get_route_result
              cities=request['Cities']
              number_of_cities=request['Number_of_Cities']
              city_count=0
              processes=[]
              pool = mp.Pool(processes=8)
              for city,destination_ip in cities.iteritems():
                   args=(type,destination_ip)
                   processes.append(args)
                   city_count=city_count+1
                   if city_count==number_of_cities:
                        break 
              pool.map(self.get_route_process,processes)  
  
  
  
  
      def get_route_process(self,HOST,destination):
            #Do Something
  </code></pre>
  
  <p>But the error I get is:-</p>
  
  <pre><code>Exception in thread Thread-1:
  Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in    __bootstrap_inner
  self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
  self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 325, in _handle_workers
  while thread._state == RUN or (pool._cache and thread._state != TERMINATE):
  AttributeError: '_MainThread' object has no attribute '_state'
  </code></pre>
  
  <p>So in a nutshell, I create a thread, which tries to create multiple processes, but the code fails. </p>