dotask 0.2.4__tar.gz → 0.2.5__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.4
2
2
  Name: dotask
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: 发布订阅注解方式
5
5
  Home-page: https://gitee.com/d-yz/task-manager
6
6
  Author: dyz
@@ -4,34 +4,21 @@ import subprocess
4
4
  from typing import Optional,Callable
5
5
 
6
6
  class Shell:
7
- _shell_semaphore:threading.Semaphore = None
8
- _semaphore_lock = threading.Lock()
7
+ # _shell_semaphore:threading.Semaphore = None
8
+ # _semaphore_lock = threading.Lock()
9
9
 
10
- def __init__(self,max_concurrent:int,global_sem=False):
11
- self.global_sem = global_sem
12
- if global_sem:
13
- if max_concurrent <= 0:
14
- raise ValueError("最大并发数必须大于0")
15
- self._shell_semaphore = threading.Semaphore(max_concurrent)
16
- self._max_concurrent = max_concurrent
17
- else:
18
- with Shell._semaphore_lock:
19
- if Shell._shell_semaphore is None:
20
- if max_concurrent <= 0:
21
- raise ValueError("最大并发数必须大于0")
22
- Shell._shell_semaphore = threading.Semaphore(max_concurrent)
23
- self._max_concurrent = max_concurrent
24
- else:
25
- if Shell._shell_semaphore._value != max_concurrent:
26
- logger.warning(f"全局信号量已存在(并发数:{Shell._shell_semaphore._value}),忽略传入的max_concurrent={max_concurrent}")
27
- self._max_concurrent = Shell._shell_semaphore._value
10
+ def __init__(self,max_concurrent:int):
11
+ if max_concurrent <= 0:
12
+ raise ValueError("最大并发数必须大于0")
13
+ self._shell_semaphore = threading.Semaphore(max_concurrent)
14
+ self._max_concurrent = max_concurrent
28
15
 
29
16
  def local_shell_execute(self,cmd:str,callback: Optional[Callable[[bool, str], None]] = None) -> bool:
30
17
  def execute_and_wait():
31
- semaphore = self._shell_semaphore if self.global_sem else Shell._shell_semaphore
32
18
 
33
- with semaphore:
34
- logger.debug(f"实例:{id(self)}-剩余并发名额: {semaphore._value} | 开始执行命令: {cmd[:50]}")
19
+
20
+ with self._shell_semaphore:
21
+ logger.debug(f"实例:{id(self)}-剩余并发名额: {self._shell_semaphore._value} | 开始执行命令: {cmd[:50]}")
35
22
  proc = None
36
23
  try:
37
24
  # 创建并执行命令
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dotask
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: 发布订阅注解方式
5
5
  Home-page: https://gitee.com/d-yz/task-manager
6
6
  Author: dyz
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = dotask
3
- version = 0.2.4
3
+ version = 0.2.5
4
4
  author = dyz
5
5
  author_email = 837701454@qq.com
6
6
  description = 发布订阅注解方式
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes