MultiServer and clients: async coroutine starter in Utils.py (#1143)

* async coroutine starter in Utils.py

* refactor from static class to function

* async_start docstring
This commit is contained in:
Doug Hoskisson
2022-11-02 07:51:35 -07:00
committed by GitHub
parent a6e1e14fee
commit da392239a0
10 changed files with 82 additions and 54 deletions

View File

@@ -49,6 +49,7 @@ fade_in_animation = Animation(opacity=0, duration=0) + Animation(opacity=1, dura
from NetUtils import JSONtoTextParser, JSONMessagePart, SlotType
from Utils import async_start
if typing.TYPE_CHECKING:
import CommonClient
@@ -427,9 +428,9 @@ class GameManager(App):
if self.ctx.server:
self.ctx.server_address = None
self.ctx.username = None
asyncio.create_task(self.ctx.disconnect())
async_start(self.ctx.disconnect())
else:
asyncio.create_task(self.ctx.connect(self.server_connect_bar.text.replace("/connect ", "")))
async_start(self.ctx.connect(self.server_connect_bar.text.replace("/connect ", "")))
def on_stop(self):
# "kill" input tasks