Charcoal-SE / SmokeDetector-ng

SmokeDetector reboot project.
Apache License 2.0
6 stars 3 forks source link

Running daemon.py results in an error #31

Closed AWegnerGitHub closed 7 years ago

AWegnerGitHub commented 7 years ago

Windows error when running daemon.py:

Traceback (most recent call last):
  File "daemon.py", line 45, in <module>
    process.start()
  File "C:\Users\Andy\AppData\Local\Programs\Python\Python36\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "C:\Users\Andy\AppData\Local\Programs\Python\Python36\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\Andy\AppData\Local\Programs\Python\Python36\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "C:\Users\Andy\AppData\Local\Programs\Python\Python36\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\Andy\AppData\Local\Programs\Python\Python36\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
_pickle.PicklingError: Can't pickle <class 'status.Handler'>: it's not the same object as status.Handler

Note from @quartata about this error:

The first error is subtle. What's happening is that we're creating an instance of status.Handler then accidentally reloading status (the module), which creates two different types in pickle's eyes and confuses the hell out of it Not a problem on UNIX since we don't need to pickle; fork copies the address space Two solutions: exclude status from being reloaded or pass in the exit code not the handler I'd like to minimize the number of modules I exclude from being reloaded (I was loathe to add command_dispatch but can't think of a better solution)


Note, the system works when running entry.py

ArtOfCode- commented 7 years ago

...I may be missing something, but why are we pickling things now we have a database?

quartata commented 7 years ago

@ArtOfCode- Since Windows doesn't have fork (which copies memory for you), multiprocessing internally passes arguments to the new process by pickling them.

quartata commented 7 years ago

https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

quartata commented 7 years ago

Fixed with a third solution :P

quartata commented 7 years ago

https://github.com/Charcoal-SE/SmokeDetector-ng/commit/6d191631c1202a2df1832691a4651ffb93f0f489