multiCMD 1.28__py3-none-any.whl → 1.29__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.
- multiCMD.py +15 -3
- {multicmd-1.28.dist-info → multicmd-1.29.dist-info}/METADATA +1 -1
- multicmd-1.29.dist-info/RECORD +6 -0
- multicmd-1.28.dist-info/RECORD +0 -6
- {multicmd-1.28.dist-info → multicmd-1.29.dist-info}/WHEEL +0 -0
- {multicmd-1.28.dist-info → multicmd-1.29.dist-info}/entry_points.txt +0 -0
- {multicmd-1.28.dist-info → multicmd-1.29.dist-info}/top_level.txt +0 -0
multiCMD.py
CHANGED
@@ -18,7 +18,7 @@ import re
|
|
18
18
|
import itertools
|
19
19
|
import signal
|
20
20
|
|
21
|
-
version = '1.
|
21
|
+
version = '1.29'
|
22
22
|
__version__ = version
|
23
23
|
|
24
24
|
__running_threads = []
|
@@ -42,7 +42,7 @@ class Task:
|
|
42
42
|
return False
|
43
43
|
|
44
44
|
class AsyncExecutor:
|
45
|
-
def __init__(self, max_threads=1,semaphore
|
45
|
+
def __init__(self, max_threads=1,semaphore=...,timeout=0,quiet=True,dry_run=False,parse=False):
|
46
46
|
'''
|
47
47
|
AsyncExecutor class to run commands in parallel asynchronously
|
48
48
|
@params:
|
@@ -54,6 +54,8 @@ class AsyncExecutor:
|
|
54
54
|
parse: Whether to parse ranged input ( bool )
|
55
55
|
'''
|
56
56
|
self.max_threads = max_threads
|
57
|
+
if semaphore is ...:
|
58
|
+
semaphore = threading.Semaphore(max_threads)
|
57
59
|
self.semaphore = semaphore
|
58
60
|
self.runningThreads = []
|
59
61
|
self.tasks = []
|
@@ -61,6 +63,7 @@ class AsyncExecutor:
|
|
61
63
|
self.quiet = quiet
|
62
64
|
self.dry_run = dry_run
|
63
65
|
self.parse = parse
|
66
|
+
self.__lastNotJoined = 0
|
64
67
|
|
65
68
|
def __iter__(self):
|
66
69
|
return iter(self.tasks)
|
@@ -103,6 +106,15 @@ class AsyncExecutor:
|
|
103
106
|
parse = self.parse
|
104
107
|
if sem is ...:
|
105
108
|
sem = self.semaphore
|
109
|
+
if len(self.runningThreads) > 130000:
|
110
|
+
self.wait(timeout=0)
|
111
|
+
if len(self.runningThreads) > 130000:
|
112
|
+
print('The amount of running threads approching cpython limit of 130704. Waiting until some available.')
|
113
|
+
while len(self.runningThreads) > 120000:
|
114
|
+
self.wait(timeout=1)
|
115
|
+
elif len(self.runningThreads) + self.__lastNotJoined > 1000:
|
116
|
+
self.wait(timeout=0)
|
117
|
+
self.__lastNotJoined = len(self.runningThreads)
|
106
118
|
taskObjects: list[Task] = run_commands(commands,timeout=timeout,max_threads=max_threads,quiet=quiet,dry_run=dry_run,with_stdErr=False,
|
107
119
|
return_code_only=False,return_object=True, parse = parse, wait_for_return = False, sem = sem)
|
108
120
|
self.tasks.extend(taskObjects)
|
@@ -139,7 +151,7 @@ class AsyncExecutor:
|
|
139
151
|
if timeout is ...:
|
140
152
|
timeout = self.timeout
|
141
153
|
for thread in threads:
|
142
|
-
if timeout
|
154
|
+
if timeout >= 0:
|
143
155
|
thread.join(timeout=timeout)
|
144
156
|
else:
|
145
157
|
thread.join()
|
@@ -0,0 +1,6 @@
|
|
1
|
+
multiCMD.py,sha256=5jTOEqw-pch56VkKQjVu9Ylw4zR8ZDCcEGwwCS9utHE,25571
|
2
|
+
multicmd-1.29.dist-info/METADATA,sha256=-2O5pV3TjRGb4kVF3GLX83_IEKuj23hFTqiM6bjqZZA,5640
|
3
|
+
multicmd-1.29.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
4
|
+
multicmd-1.29.dist-info/entry_points.txt,sha256=nSLBkYrcUCQxt1w3LIJkvgOhpRYEC0xAPqNG7u4OYs8,89
|
5
|
+
multicmd-1.29.dist-info/top_level.txt,sha256=DSqgftD40G09F3qEjpHRCUNUsGUvGZZG69Sm3YEUiWI,9
|
6
|
+
multicmd-1.29.dist-info/RECORD,,
|
multicmd-1.28.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
multiCMD.py,sha256=fgT8HBpqVnoT8HZ9bHQwFGOM5ONuJIn88ey4ITYiRP8,25050
|
2
|
-
multicmd-1.28.dist-info/METADATA,sha256=7EK4qvJSK1DheNstmVJTOq1qK9r0oGhZrlcL0JWIAEE,5640
|
3
|
-
multicmd-1.28.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
4
|
-
multicmd-1.28.dist-info/entry_points.txt,sha256=nSLBkYrcUCQxt1w3LIJkvgOhpRYEC0xAPqNG7u4OYs8,89
|
5
|
-
multicmd-1.28.dist-info/top_level.txt,sha256=DSqgftD40G09F3qEjpHRCUNUsGUvGZZG69Sm3YEUiWI,9
|
6
|
-
multicmd-1.28.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|