balatrobot 0.7.3__py3-none-any.whl → 0.7.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- balatrobot/__init__.py +1 -1
- balatrobot/client.py +16 -0
- {balatrobot-0.7.3.dist-info → balatrobot-0.7.4.dist-info}/METADATA +1 -1
- balatrobot-0.7.4.dist-info/RECORD +10 -0
- balatrobot-0.7.3.dist-info/RECORD +0 -10
- {balatrobot-0.7.3.dist-info → balatrobot-0.7.4.dist-info}/WHEEL +0 -0
- {balatrobot-0.7.3.dist-info → balatrobot-0.7.4.dist-info}/licenses/LICENSE +0 -0
balatrobot/__init__.py
CHANGED
balatrobot/client.py
CHANGED
|
@@ -6,6 +6,7 @@ import platform
|
|
|
6
6
|
import re
|
|
7
7
|
import shutil
|
|
8
8
|
import socket
|
|
9
|
+
import time
|
|
9
10
|
from pathlib import Path
|
|
10
11
|
from typing import Self
|
|
11
12
|
|
|
@@ -186,6 +187,9 @@ class BalatroClient:
|
|
|
186
187
|
logger.debug(f"Sending API request: {name}")
|
|
187
188
|
|
|
188
189
|
try:
|
|
190
|
+
# Start timing measurement
|
|
191
|
+
start_time = time.perf_counter()
|
|
192
|
+
|
|
189
193
|
# Send request
|
|
190
194
|
message = request.model_dump_json() + "\n"
|
|
191
195
|
self._socket.send(message.encode())
|
|
@@ -216,6 +220,18 @@ class BalatroClient:
|
|
|
216
220
|
logger.debug(f"API request {name} completed successfully")
|
|
217
221
|
return response_data
|
|
218
222
|
|
|
223
|
+
except socket.timeout as e:
|
|
224
|
+
# Calculate elapsed time and log timeout
|
|
225
|
+
elapsed_time = time.perf_counter() - start_time
|
|
226
|
+
logger.warning(
|
|
227
|
+
f"Timeout on API request {name}: took {elapsed_time:.3f}s, "
|
|
228
|
+
f"exceeded timeout of {self.timeout}s (port: {self.port})"
|
|
229
|
+
)
|
|
230
|
+
raise ConnectionFailedError(
|
|
231
|
+
f"Socket timeout during communication: {e}",
|
|
232
|
+
error_code="E008",
|
|
233
|
+
context={"error": str(e), "elapsed_time": elapsed_time},
|
|
234
|
+
) from e
|
|
219
235
|
except socket.error as e:
|
|
220
236
|
logger.error(f"Socket error during API request {name}: {e}")
|
|
221
237
|
raise ConnectionFailedError(
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
balatrobot/__init__.py,sha256=sn-gdztWJAELq4WCWhtOQVIu3r4fguVwb9YP6JEn4TU,406
|
|
2
|
+
balatrobot/client.py,sha256=pXPKmTh3hQpt0wMQG9wZSNFD47x-pwHbqspndjApAcE,18664
|
|
3
|
+
balatrobot/enums.py,sha256=UzlrljX1x_UlbuqR87c-KrCQjS74DGpG8A0zH0G-h98,22463
|
|
4
|
+
balatrobot/exceptions.py,sha256=fRupkYMw4PuMCJd8SFjfBDlla8wiKwhVzLj8AxmVL9I,4046
|
|
5
|
+
balatrobot/models.py,sha256=me9-qN1LQtnWfReC8tF8DFR38d5hBBSJD1SfUF3d2b4,14996
|
|
6
|
+
balatrobot/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
balatrobot-0.7.4.dist-info/METADATA,sha256=iFVGpa27v74dlCNe9ix5qEHTVq9WDjYCL-6GpFUp_EM,2801
|
|
8
|
+
balatrobot-0.7.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
+
balatrobot-0.7.4.dist-info/licenses/LICENSE,sha256=71EXhU7CSe-Cihhj_VVxLtgVnSOaavHqVoixPKtE7Bk,1064
|
|
10
|
+
balatrobot-0.7.4.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
balatrobot/__init__.py,sha256=VUudB2uHb5OSd1vqnKW17Ir6iU0ecIWe20LtXHLQDqw,406
|
|
2
|
-
balatrobot/client.py,sha256=qx9EMkZEbZahd6wirontmxslmwejgdMTUW87GCzcYh8,17993
|
|
3
|
-
balatrobot/enums.py,sha256=UzlrljX1x_UlbuqR87c-KrCQjS74DGpG8A0zH0G-h98,22463
|
|
4
|
-
balatrobot/exceptions.py,sha256=fRupkYMw4PuMCJd8SFjfBDlla8wiKwhVzLj8AxmVL9I,4046
|
|
5
|
-
balatrobot/models.py,sha256=me9-qN1LQtnWfReC8tF8DFR38d5hBBSJD1SfUF3d2b4,14996
|
|
6
|
-
balatrobot/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
balatrobot-0.7.3.dist-info/METADATA,sha256=k791DV7ZmTe_qpj5k62bSqLD2G7dfdLI4db3k8B1Uwg,2801
|
|
8
|
-
balatrobot-0.7.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
-
balatrobot-0.7.3.dist-info/licenses/LICENSE,sha256=71EXhU7CSe-Cihhj_VVxLtgVnSOaavHqVoixPKtE7Bk,1064
|
|
10
|
-
balatrobot-0.7.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|