Tiiffi / mcrcon

Rcon client for Minecraft
https://github.com/Tiiffi/mcrcon/
zlib License
834 stars 116 forks source link

ValueError: signal only works in main thread of the main interpreter #101

Closed dotfrankruan closed 1 year ago

dotfrankruan commented 1 year ago

Hello, here's the traceback.

No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/home/frank/.local/lib/python3.10/site-packages/telegram/ext/dispatcher.py", line 557, in process_update
    handler.handle_update(update, self, check, context)
  File "/home/frank/.local/lib/python3.10/site-packages/telegram/ext/handler.py", line 199, in handle_update
    return self.callback(update, context)
  File "/home/frank/Documents/Code/minecraft-whitelisting-bot/./main.py", line 32, in register
    if mc_whitelist.add_to_whitelist(minecraft_id):
  File "/home/frank/Documents/Code/minecraft-whitelisting-bot/mc_whitelist.py", line 29, in add_to_whitelist
    with MCRcon(RCON_HOSTNAME, RCON_PASSWORD, port=RCON_PORT) as mcr:
  File "/home/frank/.local/lib/python3.10/site-packages/mcrcon.py", line 54, in __init__
    signal.signal(signal.SIGALRM, timeout_handler)
  File "/usr/lib/python3.10/signal.py", line 56, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread of the main interpreter

I was trying to code a Telegram bot that allows users to type in their username and using rcon to add them to the whitelist of the server, but it seems it doesn't work.