2

蟒蛇代码::

from dask.distributed import variable, Client
from multiprocessing import Process, current_process

def my_task(proc):
    print("process object::", proc)

def doubler(number):
    # do stuff returns something

proc = Process(target=doubler, args=(numbers,)) # creating a python process
client = Client()
future = client.submit(my_task, proc)

运行上述代码后,我收到 proc 对象的序列化错误。请帮我解决这里的问题..

distributed.protocol.pickle - INFO - Failed to serialize (<Process(Process-1, initial)>,). Exception: Pickling an AuthenticationString object is disallowed for security reasons
Traceback (most recent call last):
  File "stop_task.py", line 42, in <module>
    future = client.submit(my_task, proc)
  File "/usr/lib/python2.7/site-packages/distributed/client.py", line 1121, in submit
    retries={skey: retries} if retries else None)
  File "/usr/lib/python2.7/site-packages/distributed/client.py", line 1954, in _graph_to_futures
    'tasks': valmap(dumps_task, dsk3),
  File "/usr/lib/python2.7/site-packages/toolz/dicttoolz.py", line 84, in valmap
    rv.update(zip(iterkeys(d), map(func, itervalues(d))))
  File "/usr/lib/python2.7/site-packages/distributed/worker.py", line 703, in dumps_task
    'args': pickle.dumps(task[1:])}
  File "/usr/lib/python2.7/site-packages/distributed/protocol/pickle.py", line 51, in dumps
    return cloudpickle.dumps(x, protocol=pickle.HIGHEST_PROTOCOL)
  File "/usr/lib/python2.7/site-packages/cloudpickle/cloudpickle.py", line 881, in dumps
    cp.dump(obj)
  File "/usr/lib/python2.7/site-packages/cloudpickle/cloudpickle.py", line 268, in dump
    return Pickler.dump(self, obj)
  File "/usr/lib64/python2.7/pickle.py", line 224, in dump
    self.save(obj)
  File "/usr/lib64/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib64/python2.7/pickle.py", line 548, in save_tuple
    save(element)
  File "/usr/lib64/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/usr/lib64/python2.7/pickle.py", line 419, in save_reduce
    save(state)
  File "/usr/lib64/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/usr/lib64/python2.7/pickle.py", line 649, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/usr/lib64/python2.7/pickle.py", line 681, in _batch_setitems
    save(v)
  File "/usr/lib64/python2.7/pickle.py", line 306, in save
    rv = reduce(self.proto)
  File "/usr/lib64/python2.7/multiprocessing/process.py", line 290, in __reduce__
    'Pickling an AuthenticationString object is '
TypeError: Pickling an AuthenticationString object is disallowed for security reasons

不知道这里出了什么问题..感谢您的时间和帮助..谢谢..

4

1 回答 1

1

看起来Process对象不可序列化。这并不奇怪。一Process台机器上的 A 不能很好地转换为其他机器上的进程。这种对象太难移动,因此无法序列化。

于 2018-01-09T15:45:00.787 回答