Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-black-tea committed Dec 30, 2024
1 parent fece4c7 commit 5dc8ddd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def append_module(self, path, script_prefix, module_prefix):
if find:
items.append(int(find[0]))
version = ".".join(map(str, items))
version = f"{version}.post0.dev0"
version = f"{version}.post100.dev0"

with open(get_src_path("template", "tools.yml"), "rb") as fd_in, \
open(get_src_path("assets", "tools.json"), "wt") as fd_out:
Expand Down
13 changes: 4 additions & 9 deletions src/linktools/utils/_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,16 @@ class Process(subprocess.Popen):
def call(self, timeout: TimeoutType = None) -> int:
with self:
try:
return utils.wait_process(self, timeout.remain)
except Exception:
return self.wait(timeout.remain)
except:
self.recursive_kill()
raise

@timeoutable
def check_call(self, timeout: TimeoutType = None) -> int:
with self:
try:
retcode = utils.wait_process(self, timeout.remain)
retcode = self.wait(timeout.remain)
if retcode:
raise subprocess.CalledProcessError(retcode, self.args)
return retcode
Expand All @@ -176,7 +176,6 @@ def fetch(self, timeout: TimeoutType = None) -> "Generator[Tuple[Optional[AnyStr
:return: 返回stdout输出内容和stderr错误内容
"""
if self.stdout or self.stderr:

for code, data in self._output.get(timeout):
out = err = None
if code == STDOUT:
Expand All @@ -185,11 +184,7 @@ def fetch(self, timeout: TimeoutType = None) -> "Generator[Tuple[Optional[AnyStr
err = data
yield out, err
else:

try:
utils.wait_process(self, timeout)
except subprocess.TimeoutExpired:
pass
utils.wait_process(self, timeout)

def recursive_kill(self) -> None:
try:
Expand Down
10 changes: 4 additions & 6 deletions src/linktools/utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,17 +860,15 @@ def wait_thread(thread: threading.Thread, timeout: TimeoutType) -> bool:


@timeoutable
def wait_process(process: subprocess.Popen, timeout: TimeoutType) -> bool:
def wait_process(process: subprocess.Popen, timeout: TimeoutType) -> "Optional[int]":
interval = 1
while True:
t = timeout.remain
if t is None:
t = interval
elif t <= 0:
return False
return None
try:
process.wait(min(t, interval))
except:
return process.wait(min(t, interval))
except subprocess.TimeoutExpired:
pass
if process.poll() is not None:
return True

0 comments on commit 5dc8ddd

Please sign in to comment.