multiCMD 1.22__tar.gz → 1.23__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: multiCMD
3
- Version: 1.22
3
+ Version: 1.23
4
4
  Summary: Run commands simultaneously
5
5
  Home-page: https://github.com/yufei-pan/multiCMD
6
6
  Author: Yufei Pan
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: multiCMD
3
- Version: 1.22
3
+ Version: 1.23
4
4
  Summary: Run commands simultaneously
5
5
  Home-page: https://github.com/yufei-pan/multiCMD
6
6
  Author: Yufei Pan
@@ -18,7 +18,7 @@ import re
18
18
  import itertools
19
19
  import signal
20
20
 
21
- version = '1.22'
21
+ version = '1.23'
22
22
  __version__ = version
23
23
 
24
24
  __running_threads = []
@@ -28,6 +28,7 @@ class Task:
28
28
  self.returncode = None
29
29
  self.stdout = []
30
30
  self.stderr = []
31
+ self.thread = None
31
32
  self.stop = False
32
33
  def __iter__(self):
33
34
  return zip(['command', 'returncode', 'stdout', 'stderr'], [self.command, self.returncode, self.stdout, self.stderr])
@@ -35,6 +36,10 @@ class Task:
35
36
  return f'Task(command={self.command}, returncode={self.returncode}, stdout={self.stdout}, stderr={self.stderr}, stop={self.stop})'
36
37
  def __str__(self):
37
38
  return str(dict(self))
39
+ def is_alive(self):
40
+ if self.thread is not None:
41
+ return self.thread.is_alive()
42
+ return False
38
43
 
39
44
  def _expand_ranges(inStr):
40
45
  '''
@@ -350,7 +355,8 @@ def run_commands(commands, timeout=0,max_threads=1,quiet=False,dry_run=False,wit
350
355
  if max_threads > 1 or not wait_for_return:
351
356
  sem = threading.Semaphore(max_threads) # Limit concurrent sessions
352
357
  threads = [threading.Thread(target=__run_command, args=(task,sem,timeout,quiet,dry_run,...),daemon=True) for task in tasks]
353
- for thread in threads:
358
+ for thread,task in zip(threads,tasks):
359
+ task.thread = thread
354
360
  thread.start()
355
361
  if wait_for_return:
356
362
  for thread in threads:
File without changes
File without changes
File without changes