atomicshop 2.19.1__py3-none-any.whl → 2.19.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.
Potentially problematic release.
This version of atomicshop might be problematic. Click here for more details.
- atomicshop/__init__.py +1 -1
- atomicshop/basics/multiprocesses.py +32 -38
- {atomicshop-2.19.1.dist-info → atomicshop-2.19.2.dist-info}/METADATA +1 -1
- {atomicshop-2.19.1.dist-info → atomicshop-2.19.2.dist-info}/RECORD +7 -7
- {atomicshop-2.19.1.dist-info → atomicshop-2.19.2.dist-info}/LICENSE.txt +0 -0
- {atomicshop-2.19.1.dist-info → atomicshop-2.19.2.dist-info}/WHEEL +0 -0
- {atomicshop-2.19.1.dist-info → atomicshop-2.19.2.dist-info}/top_level.txt +0 -0
atomicshop/__init__.py
CHANGED
|
@@ -3,6 +3,7 @@ import multiprocessing.managers
|
|
|
3
3
|
import queue
|
|
4
4
|
import concurrent.futures
|
|
5
5
|
from concurrent.futures import ProcessPoolExecutor, as_completed
|
|
6
|
+
from typing import Callable
|
|
6
7
|
|
|
7
8
|
from ..import system_resources
|
|
8
9
|
|
|
@@ -38,7 +39,7 @@ def process_wrap_queue(function_reference, *args, **kwargs):
|
|
|
38
39
|
class MultiProcessorRecursive:
|
|
39
40
|
def __init__(
|
|
40
41
|
self,
|
|
41
|
-
process_function,
|
|
42
|
+
process_function: Callable,
|
|
42
43
|
input_list: list,
|
|
43
44
|
max_workers: int = None,
|
|
44
45
|
cpu_percent_max: int = 80,
|
|
@@ -138,7 +139,7 @@ class MultiProcessorRecursive:
|
|
|
138
139
|
processor.shutdown_pool()
|
|
139
140
|
"""
|
|
140
141
|
|
|
141
|
-
self.process_function = process_function
|
|
142
|
+
self.process_function: Callable = process_function
|
|
142
143
|
self.input_list: list = input_list
|
|
143
144
|
self.max_workers: int = max_workers
|
|
144
145
|
self.cpu_percent_max: int = cpu_percent_max
|
|
@@ -153,43 +154,36 @@ class MultiProcessorRecursive:
|
|
|
153
154
|
self.async_results: list = []
|
|
154
155
|
|
|
155
156
|
def run_process(self):
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
async_result = self.pool.apply_async(self.process_function, (item,))
|
|
173
|
-
self.async_results.append(async_result)
|
|
174
|
-
|
|
175
|
-
# Clear the input_list now that tasks are scheduled
|
|
176
|
-
self.input_list = []
|
|
177
|
-
|
|
178
|
-
# Collect results for the tasks that were scheduled
|
|
179
|
-
for async_result in self.async_results:
|
|
180
|
-
try:
|
|
181
|
-
result = async_result.get() # Blocking wait for result
|
|
182
|
-
# Assuming process_function returns a list, extend new_input_list
|
|
183
|
-
new_input_list.extend(result)
|
|
184
|
-
except Exception as e:
|
|
185
|
-
# Handle exceptions as needed
|
|
186
|
-
raise e
|
|
187
|
-
|
|
188
|
-
# Clear collected async results since they've been processed
|
|
189
|
-
self.async_results.clear()
|
|
157
|
+
while self.input_list:
|
|
158
|
+
new_input_list = []
|
|
159
|
+
for item in self.input_list:
|
|
160
|
+
# Check system resources before processing each item
|
|
161
|
+
system_resources.wait_for_resource_availability(
|
|
162
|
+
cpu_percent_max=self.cpu_percent_max,
|
|
163
|
+
memory_percent_max=self.memory_percent_max,
|
|
164
|
+
wait_time=self.wait_time,
|
|
165
|
+
system_monitor_manager_dict=self.system_monitor_manager_dict)
|
|
166
|
+
|
|
167
|
+
# Process the item
|
|
168
|
+
async_result = self.pool.apply_async(self.process_function, (item,))
|
|
169
|
+
self.async_results.append(async_result)
|
|
170
|
+
|
|
171
|
+
# Reset input_list for next round of processing
|
|
172
|
+
self.input_list = []
|
|
190
173
|
|
|
191
|
-
|
|
192
|
-
|
|
174
|
+
# Collect results as they complete
|
|
175
|
+
for async_result in self.async_results:
|
|
176
|
+
try:
|
|
177
|
+
result = async_result.get()
|
|
178
|
+
# Assuming process_function returns a list, extend new_input_list
|
|
179
|
+
new_input_list.extend(result)
|
|
180
|
+
except Exception:
|
|
181
|
+
raise
|
|
182
|
+
|
|
183
|
+
# Update the input_list for the next iteration
|
|
184
|
+
self.input_list = new_input_list
|
|
185
|
+
# Clear the async_results for the next iteration
|
|
186
|
+
self.async_results.clear()
|
|
193
187
|
|
|
194
188
|
def shutdown_pool(self):
|
|
195
189
|
"""Shuts down the pool gracefully."""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
atomicshop/__init__.py,sha256=
|
|
1
|
+
atomicshop/__init__.py,sha256=SBk9Y1eYsyMmy9xWJ483qY8NFoOX5qMgy1HMpVCjXO0,123
|
|
2
2
|
atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
|
|
3
3
|
atomicshop/_create_pdf_demo.py,sha256=Yi-PGZuMg0RKvQmLqVeLIZYadqEZwUm-4A9JxBl_vYA,3713
|
|
4
4
|
atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
|
|
@@ -101,7 +101,7 @@ atomicshop/basics/isinstancing.py,sha256=fQ35xfqbguQz2BUn-3a4KVGskhTcIn8JjRtxV2r
|
|
|
101
101
|
atomicshop/basics/list_of_classes.py,sha256=PJoE1VJdhhQ4gSFr88zW7IApXd4Ez7xLz-7vAM-7gug,978
|
|
102
102
|
atomicshop/basics/list_of_dicts.py,sha256=tj0LNPf1ljNI_qpoO-PiOT4Ulmk1M-UpTGyn9twVcw8,8039
|
|
103
103
|
atomicshop/basics/lists.py,sha256=I0C62vrDrNwCTNl0EjUZNa1Jsd8l0rTkp28GEx9QoEI,4258
|
|
104
|
-
atomicshop/basics/multiprocesses.py,sha256=
|
|
104
|
+
atomicshop/basics/multiprocesses.py,sha256=vzL1lGiXpfPWbuLsQF9e7c9vbo59rITL2dBLi0CCpZ0,21741
|
|
105
105
|
atomicshop/basics/numbers.py,sha256=ESX0z_7o_ok3sOmCKAUBoZinATklgMy2v-4RndqXlVM,1837
|
|
106
106
|
atomicshop/basics/package_module.py,sha256=fBd0uVgFce25ZCVtLq83iyowRlbwdWYFj_t4Ml7LU14,391
|
|
107
107
|
atomicshop/basics/randoms.py,sha256=DmYLtnIhDK29tAQrGP1Nt-A-v8WC7WIEB8Edi-nk3N4,282
|
|
@@ -322,8 +322,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=fgMzDXI0cybwUEqAxprRmY3lqbh
|
|
|
322
322
|
atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
323
323
|
atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
|
|
324
324
|
atomicshop/wrappers/winregw/winreg_network.py,sha256=AENV88H1qDidrcpyM9OwEZxX5svfi-Jb4N6FkS1xtqA,8851
|
|
325
|
-
atomicshop-2.19.
|
|
326
|
-
atomicshop-2.19.
|
|
327
|
-
atomicshop-2.19.
|
|
328
|
-
atomicshop-2.19.
|
|
329
|
-
atomicshop-2.19.
|
|
325
|
+
atomicshop-2.19.2.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
|
|
326
|
+
atomicshop-2.19.2.dist-info/METADATA,sha256=hyYsPo_Wfx0n6Q8cdQNEWsP4RqH5_oo3og7-2M5hFBs,10630
|
|
327
|
+
atomicshop-2.19.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
328
|
+
atomicshop-2.19.2.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
|
|
329
|
+
atomicshop-2.19.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|