Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: can't pickle weakref objects when running demo in Simulator mode #7

Open
Psychim opened this issue Nov 2, 2018 · 3 comments

Comments

@Psychim
Copy link

Psychim commented Nov 2, 2018

Hi! I tried to run your demo in Simulator mode, but this error occurred after start.
Here is the traceback:

Traceback (most recent call last):  
  File "D:\ProgramData\Anaconda3\lib\site-packages\rtgraph\ui\mainWindow.py", line 62, in start  
    if self.worker.start():  
  File "D:\ProgramData\Anaconda3\lib\site-packages\rtgraph\core\worker.py", line 80, in start  
    self._acquisition_process.start()  
  File "D:\ProgramData\Anaconda3\lib\multiprocessing\process.py", line 112, in start  
    self._popen = self._Popen(self)  
  File "D:\ProgramData\Anaconda3\lib\multiprocessing\context.py", line 223, in _Popen  
    return _default_context.get_context().Process._Popen(process_obj)  
  File "D:\ProgramData\Anaconda3\lib\multiprocessing\context.py", line 322, in _Popen  
    return Popen(process_obj)  
  File "D:\ProgramData\Anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__  
    reduction.dump(process_obj, to_child)  
  File "D:\ProgramData\Anaconda3\lib\multiprocessing\reduction.py", line 60, in dump  
    ForkingPickler(file, protocol).dump(obj)  
TypeError: can't pickle weakref objects  
Traceback (most recent call last):  
  File "<string>", line 1, in <module>  
  File "D:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 105, in spawn_main  
    exitcode = _main(fd)  
  File "D:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 115, in _main  
    self = reduction.pickle.load(from_parent)  
EOFError: Ran out of input

I found out that this error occurred because self._parser_process.start() is called before self._acquisition_process.start()

And here is my simulated program where the same error occurs:

from multiprocessing import Process,Event
import time
class TestProcess(Process):
    def __init__(self):
        Process.__init__(self)
        self._exit=Event()
    def stop(self):
        self._exit.set()
    def run(self):
        while not self._exit.is_set():
            pass
class TestProcessB(TestProcess):
    def __init__(self,p):
        Process.__init__(self)
        self._test_process=p
    def run(self):
        while not self._exit.is_set():
            print(time.time())
            time.sleep(1)
if __name__=='__main__':
    tp=TestProcess()
    tpb=TestProcessB(tp)
    tp.start()
    tpb.start()
    time.sleep(10)
    tp.stop()
    tpb.stop()

How can this problem be fixed?

@Psychim
Copy link
Author

Psychim commented Nov 2, 2018

I found the official response to this problem: https://bugs.python.org/issue34034

It could be many different things. The bottom line here, though, is that the Process class is not designed to be picklable (how would it work?), which is probably why you're seeing this.

It happens to be OK in python 3.4-3.6

@Psychim
Copy link
Author

Psychim commented Nov 2, 2018

Would you please fix this problem (to support python 3.7 and future versions)?

@tgterra
Copy link

tgterra commented Mar 12, 2019

I had the same problem with serial and export to CSV enable...

Im using python 3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants