From 8136cba161fc17ef284b5d06fbac9bd725c6e4b1 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Wed, 31 Aug 2022 16:44:44 +0100 Subject: [PATCH] add global lock to Client run --- mcipc/rcon/client.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mcipc/rcon/client.py b/mcipc/rcon/client.py index 4ef3655..2a25693 100644 --- a/mcipc/rcon/client.py +++ b/mcipc/rcon/client.py @@ -1,11 +1,14 @@ """Minecraft-specific client.""" -from rcon import source +from threading import Lock from mcipc.rcon.functions import str_until_none +from rcon import source + +__all__ = ["Client"] -__all__ = ['Client'] +LOCK = Lock() class Client(source.Client): @@ -13,4 +16,6 @@ class Client(source.Client): def run(self, command: str, *arguments: str) -> str: """Runs the command with additional checks.""" - return super().run(*str_until_none(command, *arguments)) + + with LOCK: + return super().run(*str_until_none(command, *arguments))