gnetclisdk 1.1.0__tar.gz → 1.1.1__tar.gz
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.
Potentially problematic release.
This version of gnetclisdk might be problematic. Click here for more details.
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/PKG-INFO +1 -1
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk/starter.py +23 -4
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk.egg-info/PKG-INFO +1 -1
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/MANIFEST.in +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/README.md +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk/auth.py +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk/client.py +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk/config.py +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk/exceptions.py +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk/interceptors.py +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk/proto/server_pb2.py +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk/proto/server_pb2.pyi +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk/proto/server_pb2_grpc.py +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk.egg-info/SOURCES.txt +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk.egg-info/dependency_links.txt +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk.egg-info/requires.txt +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/gnetclisdk.egg-info/top_level.txt +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/pyproject.toml +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/requirements.txt +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/setup.cfg +0 -0
- {gnetclisdk-1.1.0 → gnetclisdk-1.1.1}/setup.py +0 -0
|
@@ -3,7 +3,7 @@ import json
|
|
|
3
3
|
import logging
|
|
4
4
|
from asyncio.subprocess import Process
|
|
5
5
|
from json import JSONDecodeError
|
|
6
|
-
from subprocess import DEVNULL, PIPE
|
|
6
|
+
from subprocess import DEVNULL, PIPE
|
|
7
7
|
|
|
8
8
|
from gnetclisdk.config import Config, LogConfig, AuthAppConfig, config_to_yaml
|
|
9
9
|
|
|
@@ -29,6 +29,7 @@ class GnetcliStarter:
|
|
|
29
29
|
self._proc: Process | None = None
|
|
30
30
|
self._start_timeout = start_timeout
|
|
31
31
|
self._stop_timeout = stop_timeout
|
|
32
|
+
self._reader_task: asyncio.Task | None = None
|
|
32
33
|
|
|
33
34
|
async def _start(self) -> Process:
|
|
34
35
|
logger.debug("Starting Gnetcli server: %s", self._server_path)
|
|
@@ -50,7 +51,7 @@ class GnetcliStarter:
|
|
|
50
51
|
async def _wait_url(self) -> str:
|
|
51
52
|
while proc := self._proc:
|
|
52
53
|
output = await proc.stderr.readline()
|
|
53
|
-
if output
|
|
54
|
+
if not output and proc.returncode is not None:
|
|
54
55
|
break
|
|
55
56
|
if not output:
|
|
56
57
|
continue
|
|
@@ -73,13 +74,26 @@ class GnetcliStarter:
|
|
|
73
74
|
async def __aenter__(self) -> str:
|
|
74
75
|
self._proc = await self._start()
|
|
75
76
|
try:
|
|
76
|
-
|
|
77
|
+
url = await asyncio.wait_for(
|
|
77
78
|
self._wait_url(), timeout=self._start_timeout
|
|
78
79
|
)
|
|
79
80
|
except asyncio.TimeoutError:
|
|
80
81
|
logger.error("gnetcli _wait_url timeout, terminating")
|
|
81
82
|
await self._terminate()
|
|
82
83
|
raise RuntimeError("gnetcli start failed")
|
|
84
|
+
logger.info("gnetcli started with url: %s", url)
|
|
85
|
+
self._reader_task = asyncio.create_task(self._communicate())
|
|
86
|
+
return url
|
|
87
|
+
|
|
88
|
+
async def _communicate(self) -> None:
|
|
89
|
+
while proc := self._proc:
|
|
90
|
+
output = await proc.stderr.readline()
|
|
91
|
+
if not output and proc.returncode is not None:
|
|
92
|
+
logger.debug("stop reading, gnetcli terminated")
|
|
93
|
+
return
|
|
94
|
+
if not output:
|
|
95
|
+
continue
|
|
96
|
+
logger.debug("gnetcli output: %s", output.strip())
|
|
83
97
|
|
|
84
98
|
async def _terminate(self) -> None:
|
|
85
99
|
if (proc := self._proc) is None:
|
|
@@ -89,12 +103,17 @@ class GnetcliStarter:
|
|
|
89
103
|
"gnetcli already terminated with code: %s", proc.returncode
|
|
90
104
|
)
|
|
91
105
|
return
|
|
106
|
+
logger.debug("terminate gnetcli")
|
|
92
107
|
proc.terminate()
|
|
93
108
|
try:
|
|
94
109
|
await asyncio.wait_for(proc.wait(), timeout=self._stop_timeout)
|
|
95
|
-
except
|
|
110
|
+
except TimeoutError:
|
|
96
111
|
logger.debug("gnetcli terminate failed, killing")
|
|
97
112
|
self._proc.kill()
|
|
113
|
+
logger.debug("gnetcli terminated with code: %s", proc.returncode)
|
|
114
|
+
if self._reader_task is not None and not self._reader_task.cancel() and not self._reader_task.cancelling():
|
|
115
|
+
self._reader_task.cancel()
|
|
116
|
+
self._reader_task = None
|
|
98
117
|
self._proc = None
|
|
99
118
|
|
|
100
119
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|