title: Can't pickle <type 'instancemethod'> when using multiprocessing Pool.map()
body: <p>I'm trying to use <code>multiprocessing</code>'s <code>Pool.map()</code> function to divide out work simultaneously. When I use the following code, it works fine:</p>
  
  <pre><code>import multiprocessing
  
  def f(x):
      return x*x
  
  def go():
      pool = multiprocessing.Pool(processes=4)        
      print pool.map(f, range(10))
  
  
  if __name__== '__main__' :
      go()
  </code></pre>
  
  <p>However, when I use it in a more object-oriented approach, it doesn't work. The error message it gives is:</p>
  
  <pre class="lang-none prettyprint-override"><code>PicklingError: Can't pickle &lt;type 'instancemethod'&gt;: attribute lookup
  __builtin__.instancemethod failed
  </code></pre>
  
  <p>This occurs when the following is my main program:</p>
  
  <pre><code>import someClass
  
  if __name__== '__main__' :
      sc = someClass.someClass()
      sc.go()
  </code></pre>
  
  <p>and the following is my <code>someClass</code> class:</p>
  
  <pre><code>import multiprocessing
  
  class someClass(object):
      def __init__(self):
          pass
  
      def f(self, x):
          return x*x
  
      def go(self):
          pool = multiprocessing.Pool(processes=4)       
          print pool.map(self.f, range(10))
  </code></pre>
  
  <p>Anyone know what the problem could be, or an easy way around it?</p>