title: Can't pickle <type 'cStringIO.StringO'>: attribute lookup cStringIO.StringO failed error while using multithreading module
body: <pre><code>def execute_on_host((hostname, command), username=config['username'], keyfile=config['keyfile']):
  
      print hostname
      ssh_client = paramiko.SSHClient()
      ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
      ssh_client.connect(hostname=hostname, username=username, key_filename=keyfile)
      stdin, stdout, stderr = ssh_client.exec_command(command)
      print stdout.read()
      ssh_client.close()
      return stdout
  </code></pre>
  
  <p>So, after the <code>hostname</code> and <code>stdout.read()</code> is printed, I get errors like these</p>
  
  <pre><code>Process PoolWorker-1:
  Traceback (most recent call last):
    File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
      self.run()
    File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
      self._target(*self._args, **self._kwargs)
    File "/usr/lib/python2.7/multiprocessing/pool.py", line 99, in worker
      put((job, i, result))
    File "/usr/lib/python2.7/multiprocessing/queues.py", line 390, in put
      return send(obj)
  PicklingError: Can't pickle &lt;type 'cStringIO.StringO'&gt;: attribute lookup cStringIO.StringO failed
  </code></pre>
  
  <p>I am using the following code to execute the command.</p>
  
  <pre><code>from multiprocessing import Pool
  pool = Pool(len(host_cmds_list))
  pool.map(execute_on_host, host_cmds_list)
  pool.close()
  pool.join()
  </code></pre>
  
  <p>I am not sure how to fix this.</p>
  
  <pre><code>print host_cmds_list
  [('hostname1', '/bin/date'), ('hostname2', '/bin/date')]
  </code></pre>