title: Share objects with file handle attribute between processes
body: <p>I have a question about shared resource with file handle between processes.
  Here is my test code:</p>
  
  <pre><code>from multiprocessing import Process,Lock,freeze_support,Queue
  import tempfile
  #from cStringIO import StringIO
  
  class File():
      def __init__(self):
          self.temp = tempfile.TemporaryFile()
          #print self.temp
  
      def read(self):
          print "reading!!!"
          s = "huanghao is a good boy !!"
          print &gt;&gt; self.temp,s
          self.temp.seek(0,0)
  
          f_content = self.temp.read()
          print f_content
  
  class MyProcess(Process):
      def __init__(self,queue,*args,**kwargs):
          Process.__init__(self,*args,**kwargs)
          self.queue = queue
  
      def run(self):
          print "ready to get the file object"
          self.queue.get().read()
          print "file object got"
          file.read()
  
  if __name__ == "__main__":
      freeze_support()
      queue = Queue()
      file = File()
  
      queue.put(file)
      print "file just put"
  
      p = MyProcess(queue)
      p.start()
  </code></pre>
  
  <p>Then I get a <code>KeyError</code> like below:</p>
  
  <pre><code>file just put
  ready to get the file object
  Process MyProcess-1:
  Traceback (most recent call last):
    File "D:\Python26\lib\multiprocessing\process.py", line 231, in _bootstrap
      self.run()
    File "E:\tmp\mpt.py", line 35, in run
      self.queue.get().read()
    File "D:\Python26\lib\multiprocessing\queues.py", line 91, in get
      res = self._recv()
    File "D:\Python26\lib\tempfile.py", line 375, in __getattr__
      file = self.__dict__['file']
  KeyError: 'file'
  </code></pre>
  
  <p>I think when I put the <code>File()</code> object into queue , the object got serialized, and file handle can not be serialized, so, i got the <code>KeyError</code>:</p>
  
  <p>Anyone have any idea about that? if I want to share objects with file handle attribute, what should I do?</p>