IRNAS / ppk2-api-python

Power Profiling Kit 2 unofficial python api.
http://irnas.eu
GNU General Public License v2.0
145 stars 37 forks source link

MP Example ctypes objects containing pointers cannot be pickled #18

Closed erickcinco closed 1 year ago

erickcinco commented 1 year ago

Has anyone experienced a ValueError: ctypes objects containing pointers cannot be pickled when start_measuring() is called when using multiprocessing?

Issue experienced using python 3.7. 3.8 and 3.9.

Found PPK2 at COM23
Traceback (most recent call last):
  File "D:\git\ppk2-api-python\example_mp.py", line 26, in <module>
    ppk2_test.start_measuring()  # start measuring
  File "C:\Python3\lib\site-packages\ppk2_api\ppk2_api.py", line 471, in start_measuring
    self._fetcher.start()
  File "C:\Python3\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Python3\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Python3\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Python3\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Python3\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
ValueError: ctypes objects containing pointers cannot be pickled
Exception ignored in: <function PPK2_MP.__del__ at 0x000001B761611430>
Traceback (most recent call last):
  File "C:\Python3\lib\site-packages\ppk2_api\ppk2_api.py", line 455, in __del__
  File "C:\Python3\lib\multiprocessing\process.py", line 148, in join
AssertionError: can only join a started process

D:\git\ppk2-api-python>Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python3\lib\multiprocessing\spawn.py", line 102, in spawn_main
    source_process = _winapi.OpenProcess(
OSError: [WinError 87] The parameter is incorrect
ghost commented 1 year ago

I have the same issue with Windows 10.

wlgrd commented 1 year ago

Does not happen in Linux. It is actually the same here https://stackoverflow.com/a/57738817/1340942. Since this is using multiprocessing, and not threading, I think you should stick to the single process example for now.

NejcKle commented 1 year ago

Closing this as it has been fixed in #21