Python2 PicklingError: Can‘t pickle <type ‘instancemethod‘>: attribute lookup __builtin__.instanceme

PicklingError: Can ‘t pickling & lt; The type ‘instancemethod & gt; : attribute lookup builtin.instancemethod failed

The Python2
** library: **multiprocessing. Pool
problem description: use the method of the class to pool. Apply_async for parameter passing error
solution: cannot use the method of the class directly copy, call the method of the class through the intermediate function, and then use the intermediate function for apply_async for parameter passing.
complete code:

#coding=utf-8
import time
from multiprocessing import Pool

class Attack:
    def __init__(self):
        pass
    
    def run(self, data):
        print '[+] ' + data + "attack exploit."
        time.sleep(3)
        return {'data': data}

# + ---------------------------------下面是一起的--------------------------------------
attacker = Attack()
def conumers_wrapper(data):
    return attacker.run(data)

class Test:
    def __init__(self):
        pass

    def _save_result(self, data):
        try:
            print '[-] _save_result -> ', data
        except Exception as e:
            print e

    def main(self):
        name = 'aquaman'
        pool = Pool(processes=20)
        for _ in range(10): 
            #            func[, args=()[, kwds={}[, callback=None]]]
            pool.apply_async(conumers_wrapper, (name,), callback=self._save_result)

        pool.close()
        pool.join()

        print "[*] finished."

if __name__ == '__main__':
    Test().main()

Read More: