title: Integrating multiprocessing.Process with concurrent.future._base.Future
body: <p>I have a requirement of creating child processes, receive results using Future and then kill some of them when required.</p>
  
  <p>For this I have subclassed multiprocessing.Process class and return a Future object from the start() method. </p>
  
  <p>The problem is that I am not able to receive the result in the cb() function as it never gets called.</p>
  
  <p>Please help/suggest if this can be done in some other way or something I am missing in my current implementation?</p>
  
  <p>Following is my current approach</p>
  
  <pre><code>from multiprocessing import Process, Queue
  from concurrent.futures import _base
  import threading
  from time import sleep
  
  
  def foo(x,q):
      print('result {}'.format(x*x))
      result = x*x
      sleep(5)
      q.put(result)
  
  
  class MyProcess(Process):
  
      def __init__(self, target, args):
          super().__init__()
          self.target = target
          self.args = args
          self.f = _base.Future()
  
      def run(self):
          q = Queue()
          worker_thread = threading.Thread(target=self.target, args=(self.args+ (q,)))
          worker_thread.start()
          r = q.get(block=True)
          print('setting result {}'.format(r))
          self.f.set_result(result=r)
          print('done setting result')
  
      def start(self):
          f = _base.Future()
          run_thread = threading.Thread(target=self.run)
          run_thread.start()
          return f
  
  
  def cb(future):
      print('received result in callback {}'.format(future))
  
  
  def main():
      p1 = MyProcess(target=foo, args=(2,))
      f = p1.start()
      f.add_done_callback(fn=cb)
  
      sleep(10)
  
  
  if __name__ == '__main__':
  
      main()
  
      print('Main thread dying')
  </code></pre>