mcpyproject / McPy

A open source Minecraft server written 100% in Python
GNU Affero General Public License v3.0
82 stars 16 forks source link

Exception starting the server #56

Closed plun1331 closed 3 years ago

plun1331 commented 3 years ago

Describe the bug Encountering 2 exceptions when running startup.py, EOFError and a TypeError

To Reproduce

  1. Run startup.py

Expected behavior The server starts

Screenshots

INFO:root:Getting release list...
INFO:root:McPy found! Running it...
[2021-01-25 11:45:48,759 - INFO - MainThread] Trying to initialize the Blackfire probe
[2021-01-25 11:45:48,760 - INFO - MainThread] Blackfire not installed: passing
[2021-01-25 11:45:48,760 - INFO - MainThread] Starting queues...
[2021-01-25 11:45:48,765 - INFO - MainThread] Started queues!
[2021-01-25 11:45:48,765 - INFO - MainThread] Trying to find number of available cores
[2021-01-25 11:45:48,765 - WARNING - MainThread] Falling back to multiprocessing cpu_count to calc cores. Most likely getaffinity is not supported on your OS
[2021-01-25 11:45:48,765 - INFO - MainThread] Found 2 cores available!
[2021-01-25 11:45:48,766 - INFO - MainThread] Starting worker ID 15824
[2021-01-25 11:45:48,771 - INFO - MainThread] Started worker.
[2021-01-25 11:45:48,882 - INFO - MainThread] Starting networking worker
Traceback (most recent call last):
  File "McPy/main.py", line 238, in <module>
    main()
  File "McPy/main.py", line 221, in main
    networkingProcess.start()
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\context.py", line 326, in _Popen
    return Popen(process_obj)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle '_cffi_backend.FFI' object
[2021-01-25 11:45:49,267 - INFO - MainThread] Trying to initialize the Blackfire probe
[2021-01-25 11:45:49,268 - INFO - MainThread] Blackfire not installed: passing
[2021-01-25 11:45:49,268 - INFO - MainThread] Starting queues...
[2021-01-25 11:45:49,272 - INFO - MainThread] Started queues!
[2021-01-25 11:45:49,273 - INFO - MainThread] Worker ID 15824 has started up.
[2021-01-25 11:45:49,375 - INFO - MainThread] Trying to initialize the Blackfire probe
[2021-01-25 11:45:49,376 - INFO - MainThread] Blackfire not installed: passing
[2021-01-25 11:45:49,376 - INFO - MainThread] Starting queues...
[2021-01-25 11:45:49,380 - INFO - MainThread] Started queues!
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\spawn.py", line 126, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input

Host system:

Additional context If it makes any difference, I installed Twisted from https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted using Twisted‑20.3.0‑cp38‑cp38‑win32.whl

Geolykt commented 3 years ago

Are you using the 32 bit version of python?

plun1331 commented 3 years ago

32, yes

Geolykt commented 3 years ago

The bug looks similar to #19, although I wouldn't yet consider it a duplicate as It should have been fixed

ntoskrnl4 commented 3 years ago

yeah that's #19 reincarnated, rip

make sure that you're using the latest version of master branch, also try develop

plun1331 commented 3 years ago

Cloned the repo about 20 minutes ago, I'll try develop

plun1331 commented 3 years ago

Problem persists on the develop branch

Geolykt commented 3 years ago

Do you still get that blackfire probe stuff twice or is it once again? I'm wondering if it's a hint towards a malfunction within the application

plun1331 commented 3 years ago

I believe I get it twice

Geolykt commented 3 years ago

Could you send the updated log (using the develop branch)?

plun1331 commented 3 years ago
INFO:root:Making sure pip is installed...
Looking in links: c:\Users\USER\AppData\Local\Temp\tmpdbfedzbl
Requirement already up-to-date: setuptools in c:\users\USER\documents\github\mcpy\venv\lib\site-packages (52.0.0)
Requirement already up-to-date: pip in c:\users\USER\documents\github\mcpy\venv\lib\site-packages (21.0)
Installed.
Getting release list...
McPy found! Running it...
[2021-01-25 12:23:17,956 - INFO - MainThread] Trying to initialize the Blackfire probe
[2021-01-25 12:23:17,957 - INFO - MainThread] Blackfire not installed: passing
[2021-01-25 12:23:17,957 - INFO - MainThread] Starting queues...
[2021-01-25 12:23:17,963 - INFO - MainThread] Started queues!
[2021-01-25 12:23:17,963 - INFO - MainThread] Trying to find number of available cores
[2021-01-25 12:23:17,963 - WARNING - MainThread] Falling back to multiprocessing cpu_count to calc cores. Most likely getaffinity is not supported on your OS
[2021-01-25 12:23:17,963 - INFO - MainThread] Found 2 cores available!
[2021-01-25 12:23:17,963 - INFO - MainThread] Starting worker ID 5369
[2021-01-25 12:23:17,968 - INFO - MainThread] Started worker.
[2021-01-25 12:23:17,979 - INFO - MainThread] Starting networking worker
Traceback (most recent call last):
  File "McPy/main.py", line 238, in <module>
    main()
  File "McPy/main.py", line 221, in main
    networkingProcess.start()
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\context.py", line 326, in _Popen
    return Popen(process_obj)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\cplun\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle '_cffi_backend.FFI' object
[2021-01-25 12:23:18,466 - INFO - MainThread] Trying to initialize the Blackfire probe
[2021-01-25 12:23:18,467 - INFO - MainThread] Blackfire not installed: passing
[2021-01-25 12:23:18,467 - INFO - MainThread] Starting queues...
[2021-01-25 12:23:18,471 - INFO - MainThread] Started queues!
[2021-01-25 12:23:18,472 - INFO - MainThread] Worker ID 5369 has started up.
[2021-01-25 12:23:18,483 - INFO - MainThread] Trying to initialize the Blackfire probe
[2021-01-25 12:23:18,483 - INFO - MainThread] Blackfire not installed: passing
[2021-01-25 12:23:18,483 - INFO - MainThread] Starting queues...
[2021-01-25 12:23:18,487 - INFO - MainThread] Started queues!
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\spawn.py", line 126, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
ntoskrnl4 commented 3 years ago

Hmm, in the process of debugging I've made an interesting discovery - running the program via startup.py incurs different behavior (the error being discussed here) than directly running main.py (circular import in classes\__init__.py: from . import blocks). Nevermind, I didn't realize startup.py downloads its own McPy into a subfolder. That kinda screws with my Pycharm run configurations...

Anyways, I am able to reproduce this specific problem (W10 1909, 3.8.0 x64). Yikes. My first thought is that maybe it has to do with code being ran multiple times in the worker threads when it's not supposed to.

Geolykt commented 3 years ago

Good catch, that main.py appears outdated. @plun1331 try invoking main.py directly (in the same folder startup.py is located at), see if that helps

plun1331 commented 3 years ago

ImportError: cannot import name 'Blocks' from partially initialized module 'classes' (most likely due to a circular import) (C:\Users\cplun\Documents\GitHub\McPy\classes\__init__.py)

ntoskrnl4 commented 3 years ago

Honestly, all the stuff with startup.py is making this way more complicated than it needs to. I'm getting like 3 or 4 all different errors, depending on what branch I'm on, whether I launch using or not using startup.py...

Off-topic to this issue but I think the startup.py script should just be scrapped. It's really not hard to click the "Download zip" button in Github if anyone wants to download the program.

Geolykt commented 3 years ago

That's what #53 already does

Geolykt commented 3 years ago

@plun1331 Are you sure that you are targetting develop? I was able to reproduce this issue in master, but not in develop.

[Geolykt@<thing> McPy]$ git checkout master
warning: unable to rmdir 'libs/quarry': Directory not empty
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
[Geolykt@<thing> McPy]$ python3 main.py 
Importing classes, please wait ...
Traceback (most recent call last):
  File "/home/Geolykt/git/McPy/main.py", line 360, in <module>
    import classes
  File "/home/Geolykt/git/McPy/classes/__init__.py", line 2, in <module>
    from . import Blocks
ImportError: cannot import name 'Blocks' from partially initialized module 'classes' (most likely due to a circular import) (/home/Geolykt/git/McPy/classes/__init__.py)
[Geolykt@<thing> McPy]$ git checkout develop
Switched to branch 'develop'
Your branch is up to date with 'origin/develop'.
[Geolykt@<thing> McPy]$ python3 main.py
root | INFO | Blackfire not installed: passing
root | INFO | 4 cores available
root | INFO | Launching server ...
root | INFO | Launching processes ...
root | INFO | Starting worker PROCESS_0
root | INFO | Starting worker PROCESS_1
root | INFO | Starting worker PROCESS_2
root | INFO | Workers started !
root | INFO | Starting ticks
^Croot | INFO | Tick: Got KeyboardInterrupt, interrupting loop
root | INFO | Stopping server ...
root | INFO | Waiting for process to end ...
root | INFO | Process stopped !
root | INFO | Stopping ticks
root | INFO | Server stopped: goodbye!
plun1331 commented 3 years ago

C:\Users\user\Documents\GitHub\McPyDev>git branch
* develop

C:\Users\user\Documents\GitHub\McPyDev>python startup.py
INFO:root:Making sure pip is installed...
Looking in links: c:\Users\user\AppData\Local\Temp\tmp63ddshhe
Requirement already up-to-date: setuptools in c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages (41.2.0)
Requirement already up-to-date: pip in c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages (21.0)
Installed.
Getting release list...
McPy found! Running it...
[2021-01-25 13:00:12,452 - INFO - MainThread] Trying to initialize the Blackfire probe
[2021-01-25 13:00:12,453 - INFO - MainThread] Blackfire not installed: passing
[2021-01-25 13:00:12,453 - INFO - MainThread] Starting queues...
[2021-01-25 13:00:12,458 - INFO - MainThread] Started queues!
[2021-01-25 13:00:12,458 - INFO - MainThread] Trying to find number of available cores
[2021-01-25 13:00:12,459 - WARNING - MainThread] Falling back to multiprocessing cpu_count to calc cores. Most likely getaffinity is not supported on your OS
[2021-01-25 13:00:12,459 - INFO - MainThread] Found 2 cores available!
[2021-01-25 13:00:12,459 - INFO - MainThread] Starting worker ID 14070
[2021-01-25 13:00:12,464 - INFO - MainThread] Started worker.
[2021-01-25 13:00:12,496 - INFO - MainThread] Starting networking worker
Traceback (most recent call last):
  File "McPy/main.py", line 238, in <module>
    main()
  File "McPy/main.py", line 221, in main
    networkingProcess.start()
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\context.py", line 326, in _Popen
    return Popen(process_obj)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle '_cffi_backend.FFI' object
[2021-01-25 13:00:12,995 - INFO - MainThread] Trying to initialize the Blackfire probe
[2021-01-25 13:00:12,996 - INFO - MainThread] Blackfire not installed: passing
[2021-01-25 13:00:12,996 - INFO - MainThread] Starting queues...
[2021-01-25 13:00:13,001 - INFO - MainThread] Started queues!
[2021-01-25 13:00:13,001 - INFO - MainThread] Worker ID 14070 has started up.
[2021-01-25 13:00:13,028 - INFO - MainThread] Trying to initialize the Blackfire probe
[2021-01-25 13:00:13,029 - INFO - MainThread] Blackfire not installed: passing
[2021-01-25 13:00:13,029 - INFO - MainThread] Starting queues...
[2021-01-25 13:00:13,033 - INFO - MainThread] Started queues!
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\multiprocessing\spawn.py", line 126, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
ntoskrnl4 commented 3 years ago

@Geolykt the version of the program that startup.py runs is different than the version in the repo. You have to run McPy/main.py to get that one, which has the issue in this thread.

...I'll work on merging #53... lol

plun1331 commented 3 years ago

Well, running main.py on dev seems to work fine