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

Exception when trying to check the status of a starting server in a while loop #53

Closed
Reviville opened this issue Jun 17, 2017 · 7 comments
Labels

Comments

@Reviville
Copy link

Hey ho,

as the title already mentions, im trying to check the status of a starting minecraft server using a while-loop with server.status()

My log then shows the following exception:

AttributeError: 'TCPSocketConnection' object has no attribute 'socket' Exception ignored in: <bound method TCPSocketConnection.__del__ of <mcstatus.protocol.connection.TCPSocketConnection object at 0x7fb4005e1e10>> Traceback (most recent call last): File "/path/to/project/.venv/lib/python3.6/site-packages/mcstatus/protocol/connection.py", line 153, in __del__ self.socket.close()

If the server is up, it works. So it works if you request the server a single time, just not when trying to request it several times in a loop.
Any suggestions?

@MarkL4YG
Copy link

Seems like the problem is that there's no socket to close when the connection failed or has been closed already...
For now try initializing a new Server each time you want to check the status and see if that works as wanted.

@MarkL4YG
Copy link

@Reviville Does inactivity mean you resolved your issue or you gave up on it?

@Reviville
Copy link
Author

@MarkL4YG i gave up on it as this error still occurs.

@MarkL4YG
Copy link

MarkL4YG commented Jul 1, 2017

You may try going into mcstatus/protocol/connection.py l153 and mcstatus/protocol/connection.py l182 and replace

    def __del__(self):
        self.socket.close()

with

    def __del__(self):
        try:
            self.socket.close()
        except:
            pass

and test if the application still halts.

This by no means prevents the error, it should just pass the exception allowing the application to continue running as if nothing happened.

@Reviville
Copy link
Author

Just did.
Seems to "work" for now.
Thank you.

@MarkL4YG
Copy link

MarkL4YG commented Jul 1, 2017

@Reviville FYI The exception indicates that something in the connection failed prior to setting the socket causing a common NullPointerException when the connection is being destroyed for garbage collection.
Using such a fix should therefore not be any problem since a nonexistent socket doesn't require to be closed obviously.

I would ask you not to resolve this issue since the issue still persists in the code and adaptions are necessary to cover such a case.

@kevinkjt2000
Copy link
Collaborator

Fixed in #56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants