multiCMD 1.17__tar.gz → 1.18__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.
- {multicmd-1.17 → multicmd-1.18}/PKG-INFO +1 -1
- {multicmd-1.17 → multicmd-1.18}/multiCMD.egg-info/PKG-INFO +1 -1
- {multicmd-1.17 → multicmd-1.18}/multiCMD.py +19 -8
- {multicmd-1.17 → multicmd-1.18}/README.md +0 -0
- {multicmd-1.17 → multicmd-1.18}/multiCMD.egg-info/SOURCES.txt +0 -0
- {multicmd-1.17 → multicmd-1.18}/multiCMD.egg-info/dependency_links.txt +0 -0
- {multicmd-1.17 → multicmd-1.18}/multiCMD.egg-info/entry_points.txt +0 -0
- {multicmd-1.17 → multicmd-1.18}/multiCMD.egg-info/requires.txt +0 -0
- {multicmd-1.17 → multicmd-1.18}/multiCMD.egg-info/top_level.txt +0 -0
- {multicmd-1.17 → multicmd-1.18}/setup.cfg +0 -0
- {multicmd-1.17 → multicmd-1.18}/setup.py +0 -0
@@ -10,8 +10,9 @@ import os
|
|
10
10
|
import string
|
11
11
|
import re
|
12
12
|
import itertools
|
13
|
+
import signal
|
13
14
|
|
14
|
-
version = '1.
|
15
|
+
version = '1.18'
|
15
16
|
__version__ = version
|
16
17
|
|
17
18
|
__running_threads = []
|
@@ -21,10 +22,11 @@ class Task:
|
|
21
22
|
self.returncode = None
|
22
23
|
self.stdout = []
|
23
24
|
self.stderr = []
|
25
|
+
self.stop = False
|
24
26
|
def __iter__(self):
|
25
27
|
return zip(['command', 'returncode', 'stdout', 'stderr'], [self.command, self.returncode, self.stdout, self.stderr])
|
26
28
|
def __repr__(self):
|
27
|
-
return f'Task(command={self.command}, returncode={self.returncode}, stdout={self.stdout}, stderr={self.stderr})'
|
29
|
+
return f'Task(command={self.command}, returncode={self.returncode}, stdout={self.stdout}, stderr={self.stderr}, stop={self.stop})'
|
28
30
|
def __str__(self):
|
29
31
|
return str(dict(self))
|
30
32
|
|
@@ -194,13 +196,21 @@ def __run_command(task,sem, timeout=60, quiet=False,dry_run=False,with_stdErr=Fa
|
|
194
196
|
time.sleep(0)
|
195
197
|
sleep_time = 1.0e-8 # 10 nanoseconds
|
196
198
|
while proc.poll() is None: # while the process is still running
|
197
|
-
if
|
198
|
-
|
199
|
-
|
200
|
-
if timeout > 0 and time.time() - start_time > timeout:
|
201
|
-
task.stderr.append('Timeout!')
|
199
|
+
if task.stop:
|
200
|
+
proc.send_signal(signal.SIGINT)
|
201
|
+
time.sleep(0.01)
|
202
202
|
proc.terminate()
|
203
203
|
break
|
204
|
+
if timeout > 0:
|
205
|
+
if len(task.stdout) + len(task.stderr) != outLength:
|
206
|
+
start_time = time.time()
|
207
|
+
outLength = len(task.stdout) + len(task.stderr)
|
208
|
+
elif time.time() - start_time > timeout:
|
209
|
+
task.stderr.append('Timeout!')
|
210
|
+
proc.send_signal(signal.SIGINT)
|
211
|
+
time.sleep(0.01)
|
212
|
+
proc.terminate()
|
213
|
+
break
|
204
214
|
time.sleep(sleep_time)
|
205
215
|
# exponential backoff
|
206
216
|
if sleep_time < 0.001:
|
@@ -215,7 +225,8 @@ def __run_command(task,sem, timeout=60, quiet=False,dry_run=False,with_stdErr=Fa
|
|
215
225
|
__handle_stream(io.BytesIO(stdout),task.stdout, task)
|
216
226
|
if stderr:
|
217
227
|
__handle_stream(io.BytesIO(stderr),task.stderr, task)
|
218
|
-
task.returncode
|
228
|
+
if task.returncode is None:
|
229
|
+
task.returncode = -1
|
219
230
|
if not quiet:
|
220
231
|
print(pre+'\n'+ '-'*100+post)
|
221
232
|
print(pre+f'Process exited with return code {task.returncode}'+post)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|