Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command on a broken rcon connection results in excessive CPU Load #6

Open
Joshi425 opened this issue Nov 20, 2020 · 4 comments
Open
Labels
bug Something isn't working enhancement New feature or request

Comments

@Joshi425
Copy link

Hi there,

when I try a command on a connection where the MC Server died or restarted, it results in python using an full CPU Core:

from mcrcon import MCRcon
import time
import os

rcon = MCRcon(os.environ['RCON_HOST'],os.environ['RCON_PASSWORD'],port=int(os.environ['RCON_PORT']))
rcon.connect()
time.sleep(10) # server stopped or died here
rcon.command("list")

the command never stops. the only way to recover from that is to restart the python script. Maybe a Timeout for Command or the connection would make sense.
Related: Joshi425/minecraft-exporter#11

@unexceptable
Copy link

Sorry, haven't played with anything Minecraft related in ages, and likely won't have a chance to fix this myself. But if you feel like opening a pull request which adds a timeout I will happily review/test it, then release a new version to pypi.

@steveroch-rs
Copy link

This is an issue I assume is caused by the socket being implemented as 'blocking'. If I have time, I'll look into it and fix it so that it uses a non-blocking socket. As for now I have forked the repo and will create a pull request as soon as I have it working.

@unexceptable
Copy link

So I've now merged and released a version that supports timeout. Which should mostly handle this... but @steveroch-rs if you want to still have a go at implementing non-blocking sockets, we can instead switch to that, but timeout should work for now.

@unexceptable
Copy link

@Joshi425 can you retest and see if the timeout fixes your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants