ezKit 1.1.1__py3-none-any.whl → 1.1.2__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.
ezKit/utils.py CHANGED
@@ -5,10 +5,11 @@ import os
5
5
  import subprocess
6
6
  import time
7
7
  from copy import deepcopy
8
- from multiprocessing import Pool
8
+ from multiprocessing import Pool, Process
9
9
  from multiprocessing.pool import ThreadPool
10
10
  from pathlib import Path
11
11
  from shutil import rmtree
12
+ from threading import Thread
12
13
  from typing import Callable
13
14
  from uuid import uuid4
14
15
 
@@ -1137,7 +1138,7 @@ def process_pool(
1137
1138
  process_func: Callable = None,
1138
1139
  process_data: any = None,
1139
1140
  process_num: int = 2,
1140
- thread: bool = True,
1141
+ thread: bool = False,
1141
1142
  debug: bool = False,
1142
1143
  **kwargs
1143
1144
  ) -> list | bool:
@@ -1162,7 +1163,7 @@ def process_pool(
1162
1163
  logger.info(f"data: {_data}") if debug is True else next
1163
1164
 
1164
1165
  # 执行函数
1165
- if thread is True:
1166
+ if v_true(thread, bool):
1166
1167
  # 多线程
1167
1168
  logger.info(f"execute multi thread ......") if debug is True else next
1168
1169
  with ThreadPool(process_num, **kwargs) as p:
@@ -1178,6 +1179,27 @@ def process_pool(
1178
1179
  return False
1179
1180
 
1180
1181
 
1182
+ def new_process(
1183
+ process_func: Callable = None,
1184
+ process_data: any = None,
1185
+ thread: bool = False,
1186
+ daemon: bool = True,
1187
+ debug: bool = False,
1188
+ **kwargs
1189
+ ) -> Thread | Process | bool:
1190
+ try:
1191
+ if v_true(thread, bool):
1192
+ process = Thread(target=process_func, args=process_data, **kwargs)
1193
+ else:
1194
+ process = Process(target=process_func, args=process_data, **kwargs)
1195
+ process.daemon = daemon
1196
+ process.start()
1197
+ return process
1198
+ except Exception as e:
1199
+ logger.exception(e) if v_true(debug, bool) else next
1200
+ return False
1201
+
1202
+
1181
1203
  # --------------------------------------------------------------------------------------------------
1182
1204
 
1183
1205
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ezKit
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -9,12 +9,12 @@ ezKit/plots.py,sha256=QUtoVfZ49ZSNcY8gcQ2TYVkMjDDzoW-myMtqTi5WN2U,5322
9
9
  ezKit/redis.py,sha256=pY4SPlcgQ7S8IeY2xoDpxy-xCZxzZQrQJNAoWRsC1dI,1773
10
10
  ezKit/reports.py,sha256=dBBggggCCLuk5YD6SjdUPuxTr3wiJojP3lA7dQfg6Pk,8898
11
11
  ezKit/sendemail.py,sha256=PItznLBcZ6Om8NU7rep69m3QNZ9YkmOovup7pPGyY58,4840
12
- ezKit/utils.py,sha256=9-Rt7cSPvW_Oz0p0SonDooPxS3fGaK5o34lLnW3MKDw,41451
12
+ ezKit/utils.py,sha256=59kM_fi8Bx3NakmXPjwdDtP51GFNbVAAs8u93Fd70s0,42102
13
13
  ezKit/weixin.py,sha256=Sxm_yNEvcztFNCZyjZetVwqxoGoL2PJHlQABIWkd1pk,5075
14
14
  ezKit/xftp.py,sha256=qbCqFcGe22TDBSisj0Zoz78tnydDWoOfvywWpXdfaGw,6982
15
15
  ezKit/zabbix.py,sha256=EF0-tQ1FTMBqawXKf3JEoPYoAJmYENXXIm9T5ICSdHM,32345
16
- ezKit-1.1.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
17
- ezKit-1.1.1.dist-info/METADATA,sha256=_lmBWjtLSvMJ1-NOaNBEq_Zz4FQcHhYLObGSJzBivLg,226
18
- ezKit-1.1.1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
19
- ezKit-1.1.1.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
20
- ezKit-1.1.1.dist-info/RECORD,,
16
+ ezKit-1.1.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
17
+ ezKit-1.1.2.dist-info/METADATA,sha256=qUFiixoXP7NcXaWMpUPXpI7QHhfy8GRC-xWULNnlsOo,226
18
+ ezKit-1.1.2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
19
+ ezKit-1.1.2.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
20
+ ezKit-1.1.2.dist-info/RECORD,,
File without changes
File without changes