Can't use any ActorSystem implemenation other than simpleSystemBase on Windows
sakian-old opened this issue · comments
Mark Bremer commented
Running the following code on my Windows machine.
from thespian.actors import ActorSystem
actor_sys = ActorSystem('multiprocQueueBase')
actor_sys.shutdown()
Results in the following exception.
C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\Scripts\python.exe "C:/GITRepos/Thespian Example Project/test.py"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\Lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\Lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\Lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\Lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\Lib\runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\Lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\Lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\GITRepos\Thespian Example Project\test.py", line 3, in <module>
actor_sys = ActorSystem('multiprocQueueBase')
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\actors.py", line 635, in __init__
systemBase = self._startupActorSys(
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\actors.py", line 676, in _startupActorSys
systemBase = sbc(self, logDefs=logDefs)
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\system\multiprocQueueBase.py", line 39, in __init__
super(ActorSystemBase, self).__init__(system, logDefs)
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\system\multiprocCommon.py", line 86, in __init__
super(multiprocessCommon, self).__init__(system, logDefs)
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\system\systemBase.py", line 326, in __init__
self._startAdmin(self.adminAddr,
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\system\multiprocCommon.py", line 104, in _startAdmin
admin.start()
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\Lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\Lib\multiprocessing\context.py", line 326, in _Popen
return Popen(process_obj)
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\Lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\Lib\multiprocessing\spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "C:\Users\mark.bremer\AppData\Local\Programs\Python\Python38\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.
Traceback (most recent call last):
File "C:/GITRepos/Thespian Example Project/test.py", line 3, in <module>
actor_sys = ActorSystem('multiprocQueueBase')
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\actors.py", line 635, in __init__
systemBase = self._startupActorSys(
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\actors.py", line 676, in _startupActorSys
systemBase = sbc(self, logDefs=logDefs)
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\system\multiprocQueueBase.py", line 39, in __init__
super(ActorSystemBase, self).__init__(system, logDefs)
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\system\multiprocCommon.py", line 86, in __init__
super(multiprocessCommon, self).__init__(system, logDefs)
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\system\systemBase.py", line 326, in __init__
self._startAdmin(self.adminAddr,
File "C:\Users\mark.bremer\AppData\Roaming\SPB_Data\.virtualenvs\Thespian_Example_Project-3-gWWWf4\lib\site-packages\thespian\system\multiprocCommon.py", line 114, in _startAdmin
raise InvalidActorAddress(adminAddr,
thespian.actors.InvalidActorAddress: ActorAddr-Q.ThespianQ is not a valid ActorSystem admin
I'm not sure what I've got wrong. Any thoughts? The same code running in WSL works fine.
Mark Bremer commented
Found the solution here: https://stackoverflow.com/a/18205006/2199519
Putting my launching code in a if __name__ == '__main__':
block fixed the issue.
Kevin Quick commented
I missed this initial report while on vacation, but I'm glad you found a resolution.