mne-realtime icon indicating copy to clipboard operation
mne-realtime copied to clipboard

BUG: Get LSLMockClient to work on multiprocessing

Open teonbrooks opened this issue 6 years ago • 2 comments

Windows is causing some problems with multiprocessing in Python. look into this more

teonbrooks avatar Apr 26 '19 13:04 teonbrooks

I also meet this BUG .

huanhuangongzi avatar Sep 28 '20 02:09 huanhuangongzi

Hi,

I'm a beginner to MNE and trying to use mne-realtime on my Windows 10 PC. I was running the example code plot_lslclient_rt.py and received the following bug reports:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Program Files\Python310\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "D:\Program Files\Python310\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "D:\Program Files\Python310\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "D:\Program Files\Python310\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "D:\Program Files\Python310\lib\runpy.py", line 269, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "D:\Program Files\Python310\lib\runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "D:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "d:\WJZ\mne\plot_lslclient_rt.py", line 39, in <module>
    with MockLSLStream(host, raw, 'eeg'):
  File "D:\Program Files\Python310\lib\site-packages\mne_realtime\mock_lsl_stream.py", line 59, in __enter__
    self.start()
  File "D:\Program Files\Python310\lib\site-packages\mne_realtime\mock_lsl_stream.py", line 46, in start
    self.process.start()
  File "D:\Program Files\Python310\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "D:\Program Files\Python310\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "D:\Program Files\Python310\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "D:\Program Files\Python310\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "D:\Program Files\Python310\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "D:\Program Files\Python310\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

Is this bug ralated to this issue #9? Am I missing something or could u plz tell me if there's a way to solve this problem? Thanks!

Asudy avatar Nov 29 '21 09:11 Asudy

Same bug. currently I can't find where to put freeze_support() properly.

iPsych avatar Jan 18 '23 06:01 iPsych

hi @iPsych @Asudy, sorry for the delay, I haven't been working on this project in a while. I believe the multiprocessing on Windows has been resolved. I think if there's a problem, it might be elsewhere.

how are you currently running the example? are you using python mne-realtime/examples/plot_lslclient_rt.py

teonbrooks avatar Jan 25 '23 21:01 teonbrooks