I've written a flask based UI server that runs as it's own process and this works fine on Linux and Mac but when trying to run on Windows it freaks out, seemingly because Windows only has the spawn method and my code doesn't really support that. It fails with the following exception:
File "C:\Python36-32\Scripts\bibliopixel", line 4, in <module>
__import__('pkg_resources').run_script('BiblioPixel==3.0.6', 'bibliopixel')
File "C:\Python36-32\lib\site-packages\pkg_resources\__init__.py", line 743, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "C:\Python36-32\lib\site-packages\pkg_resources\__init__.py", line 1498, in run_script
exec(code, namespace, namespace)
File "c:\python36-32\lib\site-packages\bibliopixel-3.0.6-py3.6.egg\EGG-INFO\scripts\bibliopixel", line 15, in <module>
main.main()
File "C:\Python36-32\lib\site-packages\bibliopixel-3.0.6-py3.6.egg\bibliopixel\main\main.py", line 46, in main
result = run(args, presets) or 0
File "C:\Python36-32\lib\site-packages\bibliopixel-3.0.6-py3.6.egg\bibliopixel\main\run.py", line 36, in run
task.start()
File "C:\Python36-32\lib\site-packages\bibliopixel-3.0.6-py3.6.egg\bibliopixel\remote\control.py", line 126, in start
self.server.start()
File "C:\Python36-32\lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)
File "C:\Python36-32\lib\multiprocessing\context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Python36-32\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "C:\Python36-32\lib\multiprocessing\popen_spawn_win32.py", line 33, in __init__
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Python36-32\lib\multiprocessing\spawn.py", line 172, in get_preparation_data
main_mod_name = getattr(main_module.__spec__, "name", None)
AttributeError: module '__main__' has no attribute '__spec__'
My understanding with MP was that it prefers to be able to run a module in whole but that if you had it import a function from another module it should work fine... Since all of this is buried deep within a whole package I couldn't really find a good way to have any of this launched via a module with a proper if __name__ == "__main__" section and such.
The process is spawned here:
Which calls into the function here:
I'm new to MP so I'm probably just missing something silly but I have no clue what :P