[python-users] Problem multiprocessing

Roland Gude rg at tamedbeast.de
Do Jun 29 15:47:00 CEST 2017


Unter umständen geht es mit dill oder cloudpickle anstelle von pickle.

pathos.multiprocess ist ein multiprocessing fork der dill verwendet und deutlich mehr objekte serialisieren kann als multiprocessing.

Ob memoryview geht weiss ich aber nicht.
Roland

--
Securely sent with Tutanota. Claim your encrypted mailbox today!
https://tutanota.com

29. Jun 2017 15:19 by sasse at simply-running-systems.com:


>         Hallo, 
>     
>     ich habe ein Problem mit mulitprocessing - pickle error von    memoryview objekten 
>     Kann man das irgendwie anders lösen - evtl.  ein globales shared    Objekt ?
>     
>     Vielen Dank !
>     J. Sasse
>     
>     Traceback (most recent call last):
>       File "D:\Pythonmodule\multiProzessTest3.py", line 27, in    <module>
>         for p in procs: p.start()
>       File "C:\Python36\lib\multiprocessing\process.py", line 105, in    start
>         self._popen = self._Popen(self)
>       File "C:\Python36\lib\multiprocessing\context.py", line 223, in    _Popen
>         return    _default_context.get_context().Process._Popen(process_obj)
>       File "C:\Python36\lib\multiprocessing\context.py", line 322, in    _Popen
>         return Popen(process_obj)
>       File "C:\Python36\lib\multiprocessing\popen_spawn_win32.py", line    65, in __init__
>         reduction.dump(process_obj, to_child)
>       File "C:\Python36\lib\multiprocessing\reduction.py", line 60, in    dump
>         ForkingPickler(file, protocol).dump(obj)
>     TypeError: can't pickle memoryview objects
>     
>     
>     import time
>     from multiprocessing import Process, Value, Lock
>     
>     class Counter(object):
>         def __init__(self, initval=0):
>             self.val = Value('i', initval)
>             > self.teil = memoryview(b'Binaere Konstante')
>             self.lock = Lock()
>     
>         def increment(self):
>             with self.lock:
>                 self.val.value += 1
>     
>         def value(self):
>             with self.lock:
>                 return self.val.value
>     
>     def func(counter):
>         for i in range(50):
>             #time.sleep(0.01)
>             counter.increment()
>     
>     if __name__ == '__main__':
>         counter = Counter(0)
>         procs = [Process(target=func, args=(counter,)) for i in    range(10)]
>     
>         for p in procs: p.start()
>         for p in procs: p.join()
>     
>         print (counter.value())
>     
>     
>     > -- Mit freundlichen GrüßenJoachim Sassesimply running systems GmbH&CO.KGGrauten Ihl 2748301 Nottuln02502/4124724Geschäftsführer: Joachim SasseHRA 9162 Amtsgericht Coesfeldpersönlich haftender Gesellschafter: simply running systems Verwaltungs GmbHAmtsgericht Coesfeld HRB 16425
-------------- nächster Teil --------------
Ein Dateianhang mit HTML-Daten wurde abgetrennt...
URL: <http://lists.uni-koeln.de/pipermail/python-users/attachments/20170629/f6413f9b/attachment-0001.html>


Mehr Informationen über die Mailingliste python-users