don't stop if already stopped
This commit is contained in:
parent
ca45980bcd
commit
022ed83187
2 changed files with 5 additions and 2 deletions
|
@ -88,6 +88,7 @@ class MinecraftClient:
|
|||
await self._handshake(ConnectionState.STATUS)
|
||||
return await self._status(ping)
|
||||
finally:
|
||||
if self.dispatcher.connected:
|
||||
await self.dispatcher.disconnect()
|
||||
|
||||
async def join(self, host:str="", port:int=0, proto:int=0):
|
||||
|
@ -99,6 +100,7 @@ class MinecraftClient:
|
|||
if await self._login():
|
||||
await self._play()
|
||||
finally:
|
||||
if self.dispatcher.connected:
|
||||
await self.dispatcher.disconnect()
|
||||
|
||||
async def _handshake(self, state:ConnectionState):
|
||||
|
|
|
@ -249,6 +249,7 @@ class Dispatcher:
|
|||
await self._incoming.put(packet)
|
||||
if self.state != ConnectionState.PLAY:
|
||||
await self._incoming.join() # During play we can pre-process packets
|
||||
|
||||
except (asyncio.TimeoutError, TimeoutError):
|
||||
self.logger.error("Connection timed out")
|
||||
await self.disconnect(block=False)
|
||||
|
|
Loading…
Reference in a new issue