atomicshop 2.10.4__py3-none-any.whl → 2.10.5__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 CHANGED
@@ -1,4 +1,4 @@
1
1
  """Atomic Basic functions and classes to make developer life easier"""
2
2
 
3
3
  __author__ = "Den Kras"
4
- __version__ = '2.10.4'
4
+ __version__ = '2.10.5'
@@ -1,4 +1,5 @@
1
1
  import multiprocessing
2
+ import multiprocessing.managers
2
3
  import queue
3
4
  import concurrent.futures
4
5
  from concurrent.futures import ProcessPoolExecutor, as_completed
@@ -42,10 +43,11 @@ class MultiProcessorRecursive:
42
43
  max_workers: int = None,
43
44
  cpu_percent_max: int = 80,
44
45
  memory_percent_max: int = 80,
45
- wait_time: float = 5
46
+ wait_time: float = 5,
47
+ system_monitor_manager_dict: multiprocessing.managers.DictProxy = None
46
48
  ):
47
49
  """
48
- MultiProcessor class. Used to execute functions in parallel. The result of each execution is feeded back
50
+ MultiProcessor class. Used to execute functions in parallel. The result of each execution is fed back
49
51
  to the provided function. Making it sort of recursive execution.
50
52
  :param process_function: function, function to execute on the input list.
51
53
  :param input_list: list, list of inputs to process.
@@ -56,6 +58,12 @@ class MultiProcessorRecursive:
56
58
  :param memory_percent_max: integer, maximum memory percentage. Above that usage, we will wait, before starting
57
59
  new execution.
58
60
  :param wait_time: float, time to wait if the CPU or memory usage is above the maximum percentage.
61
+ :param system_monitor_manager_dict: multiprocessing.managers.DictProxy, shared manager dict for
62
+ system monitoring. The object is the output of atomicshop.system_resource_monitor.
63
+ If you are already running this monitor, you can pass the manager_dict to both the system monitor and this
64
+ class to share the system resources data.
65
+ If this is used, the system resources will be checked before starting each new execution from this
66
+ shared dict instead of performing new checks.
59
67
 
60
68
  Usage:
61
69
  def unpack_file(file_path):
@@ -87,6 +95,7 @@ class MultiProcessorRecursive:
87
95
  self.cpu_percent_max: int = cpu_percent_max
88
96
  self.memory_percent_max: int = memory_percent_max
89
97
  self.wait_time: float = wait_time
98
+ self.system_monitor_manager_dict: multiprocessing.managers.DictProxy = system_monitor_manager_dict
90
99
 
91
100
  def run_process(self):
92
101
  with multiprocessing.Pool(processes=self.max_workers) as pool:
@@ -100,7 +109,8 @@ class MultiProcessorRecursive:
100
109
  system_resources.wait_for_resource_availability(
101
110
  cpu_percent_max=self.cpu_percent_max,
102
111
  memory_percent_max=self.memory_percent_max,
103
- wait_time=self.wait_time)
112
+ wait_time=self.wait_time,
113
+ system_monitor_manager_dict=self.system_monitor_manager_dict)
104
114
 
105
115
  # Process the item
106
116
  async_result = pool.apply_async(self.process_function, (item,))
@@ -54,4 +54,3 @@ def convert_bytes_to_readable(
54
54
  return readable_format
55
55
  else:
56
56
  return byte_size, suffixes[i]
57
-
@@ -1,6 +1,5 @@
1
1
  from typing import Union
2
2
  import threading
3
- import multiprocessing
4
3
  import multiprocessing.managers
5
4
 
6
5
  from .print_api import print_api
@@ -22,7 +21,7 @@ class SystemResourceMonitor:
22
21
  get_disk_used_percent: bool = True,
23
22
  calculate_maximum_changed_disk_io: bool = False,
24
23
  queue_list: list = None,
25
- manager_dict = None # multiprocessing.Manager().dict()
24
+ manager_dict=None # multiprocessing.Manager().dict()
26
25
  ):
27
26
  """
28
27
  Initialize the system resource monitor.
@@ -97,7 +96,7 @@ class SystemResourceMonitor:
97
96
  self.get_disk_used_percent: bool = get_disk_used_percent
98
97
  self.calculate_maximum_changed_disk_io: bool = calculate_maximum_changed_disk_io
99
98
  self.queue_list: list = queue_list
100
- self.manager_dict: multiprocessing.Manager().dict = manager_dict
99
+ self.manager_dict = manager_dict # multiprocessing.Manager().dict()
101
100
 
102
101
  self.maximum_disk_io: dict = {
103
102
  'read_bytes_per_sec': 0,
@@ -3,6 +3,7 @@ import time
3
3
  import tempfile
4
4
  import shutil
5
5
  import threading
6
+ import multiprocessing.managers
6
7
 
7
8
  from .print_api import print_api
8
9
  from .wrappers.psutilw import cpus, memories, disks
@@ -93,18 +94,33 @@ def check_system_resources(
93
94
  return result
94
95
 
95
96
 
96
- def wait_for_resource_availability(cpu_percent_max: int = 80, memory_percent_max: int = 80, wait_time: float = 5):
97
+ def wait_for_resource_availability(
98
+ cpu_percent_max: int = 80,
99
+ memory_percent_max: int = 80,
100
+ wait_time: float = 5,
101
+ system_monitor_manager_dict: multiprocessing.managers.DictProxy = None
102
+ ):
97
103
  """
98
104
  Wait for system resources to be available.
99
105
  :param cpu_percent_max: int, maximum CPU percentage. Above that usage, we will wait.
100
106
  :param memory_percent_max: int, maximum memory percentage. Above that usage, we will wait.
101
107
  :param wait_time: float, time to wait between checks.
108
+ :param system_monitor_manager_dict: multiprocessing.managers.DictProxy, shared manager dict for
109
+ system monitoring. The object is the output of atomicshop.system_resource_monitor.
110
+ If you are already running this monitor, you can pass the manager_dict to both the system monitor and this
111
+ class to share the system resources data.
112
+ If this is used, the system resources will be checked before starting each new execution from this
113
+ shared dict instead of performing new checks.
102
114
  :return: None
103
115
  """
104
116
  while True:
105
- result = check_system_resources(
106
- get_cpu=True, get_memory=True,
107
- get_disk_io_bytes=False, get_disk_files_count=False, get_disk_busy_time=False, get_disk_used_percent=False)
117
+ if system_monitor_manager_dict:
118
+ result = system_monitor_manager_dict
119
+ else:
120
+ result = check_system_resources(
121
+ get_cpu=True, get_memory=True,
122
+ get_disk_io_bytes=False, get_disk_files_count=False, get_disk_busy_time=False, get_disk_used_percent=False)
123
+
108
124
  if result['cpu_usage'] < cpu_percent_max and result['memory_usage'] < memory_percent_max:
109
125
  break
110
126
  print_api(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.10.4
3
+ Version: 2.10.5
4
4
  Summary: Atomic functions and classes to make developer life easier
5
5
  Author: Denis Kras
6
6
  License: MIT License
@@ -1,4 +1,4 @@
1
- atomicshop/__init__.py,sha256=jiF6fRhuPCS2l3bXIdgVnGCUG5xcjtXdqlhFtq2zNTI,123
1
+ atomicshop/__init__.py,sha256=fQnAhsrGKmKYe0fp_81c4goU6Nzou40Ap0w1uxsS2jc,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
@@ -37,8 +37,8 @@ atomicshop/sound.py,sha256=KSzWRF8dkpEVXmFidIv-Eftc3kET-hQzQOxZRE7rMto,24297
37
37
  atomicshop/speech_recognize.py,sha256=55-dIjgkpF93mvJnJuxSFuft5H5eRvGNlUj9BeIOZxk,5903
38
38
  atomicshop/ssh_remote.py,sha256=Sas3nrQv8ardxR51t59xZZsYm8nvUcA7tMSqEDViRLk,17155
39
39
  atomicshop/sys_functions.py,sha256=MTBxRve5bh58SPvhX3gMiGqHlSBuI_rdNN1NnnBBWqI,906
40
- atomicshop/system_resource_monitor.py,sha256=4AqeJbfYcVrNENjEJDrFQ5jIdu--yCir8CZuPBerp9o,13697
41
- atomicshop/system_resources.py,sha256=fl8yfG1CrcsXsFzVPiTEZ82MEjcyCPj4TevKczHEKTE,8310
40
+ atomicshop/system_resource_monitor.py,sha256=ilA3wEUJfBjQhRsHDXGH7Q05mYr5KarPjRWP8S6pCTw,13681
41
+ atomicshop/system_resources.py,sha256=mcgkULCkrfMM1cu7F1fyDQQja2pJpC_pcPpwxjr_ULg,9097
42
42
  atomicshop/tempfiles.py,sha256=uq1ve2WlWehZ3NOTXJnpBBMt6HyCdBufqedF0HyzA6k,2517
43
43
  atomicshop/timer.py,sha256=KxBBgVM8po6pUJDW8TgY1UXj0iiDmRmL5XDCq0VHAfU,1670
44
44
  atomicshop/urls.py,sha256=CQl1j1kjEVDlAuYJqYD9XxPF1SUSgrmG8PjlcXNEKsQ,597
@@ -87,8 +87,8 @@ atomicshop/basics/if_else.py,sha256=MakivJChofZCpr0mOVjwCthzpiaBxXVB-zv7GwMOqVo,
87
87
  atomicshop/basics/isinstancing.py,sha256=fQ35xfqbguQz2BUn-3a4KVGskhTcIn8JjRtxV2rFcRQ,876
88
88
  atomicshop/basics/list_of_dicts.py,sha256=EeUh5FwUSmjQ7_Df7yTBgwHsou5jx3tP2a0dzgs8-fk,5773
89
89
  atomicshop/basics/lists.py,sha256=pLpYPSu0BjJIAe_Ar55XhLsH2YBhftn7b-tTAdkK1sw,3928
90
- atomicshop/basics/multiprocesses.py,sha256=AczaI4TmYduNjE6_VEQhxvDQn4VLDdXYRxhPDpjH4T0,17974
91
- atomicshop/basics/numbers.py,sha256=EDmt4M72hVE3IUqximSsrxM7HW64QQFCaGP5_fZuLPo,1839
90
+ atomicshop/basics/multiprocesses.py,sha256=nSskxJSlEdalPM_Uf8cc9kAYYlVwYM1GonBLAhCL2mM,18831
91
+ atomicshop/basics/numbers.py,sha256=ESX0z_7o_ok3sOmCKAUBoZinATklgMy2v-4RndqXlVM,1837
92
92
  atomicshop/basics/randoms.py,sha256=DmYLtnIhDK29tAQrGP1Nt-A-v8WC7WIEB8Edi-nk3N4,282
93
93
  atomicshop/basics/strings.py,sha256=aQ92AJPvb3U0O6n2FMqRUqEsPCiklwGX--jPmB9M0_s,15418
94
94
  atomicshop/basics/threads.py,sha256=xvgdDJdmgN0wmmARoZ-H7Kvl1GOcEbvgaeGL4M3Hcx8,2819
@@ -233,8 +233,8 @@ atomicshop/wrappers/socketw/socket_server_tester.py,sha256=AhpurHJmP2kgzHaUbq5ey
233
233
  atomicshop/wrappers/socketw/socket_wrapper.py,sha256=aXBwlEIJhFT0-c4i8iNlFx2It9VpCEpsv--5Oqcpxao,11624
234
234
  atomicshop/wrappers/socketw/ssl_base.py,sha256=k4V3gwkbq10MvOH4btU4onLX2GNOsSfUAdcHmL1rpVE,2274
235
235
  atomicshop/wrappers/socketw/statistics_csv.py,sha256=t3dtDEfN47CfYVi0CW6Kc2QHTEeZVyYhc57IYYh5nmA,826
236
- atomicshop-2.10.4.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
237
- atomicshop-2.10.4.dist-info/METADATA,sha256=0kskgiSsXWr6BHlxBF9mViz3QkT0EoWqwm0LKmPJdBQ,10423
238
- atomicshop-2.10.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
239
- atomicshop-2.10.4.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
240
- atomicshop-2.10.4.dist-info/RECORD,,
236
+ atomicshop-2.10.5.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
237
+ atomicshop-2.10.5.dist-info/METADATA,sha256=EYaFqDb87S7rakgkJ6Yj8B5Pqt7OtVodfUEOeZvXDew,10423
238
+ atomicshop-2.10.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
239
+ atomicshop-2.10.5.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
240
+ atomicshop-2.10.5.dist-info/RECORD,,