1
- import gc
2
- import os .path
3
- from multiprocessing import Process
1
+ import concurrent .futures
4
2
import multiprocessing
3
+ import os .path
5
4
import datetime
6
5
import time
7
- from concurrent .futures import ThreadPoolExecutor
8
- import concurrent .futures
9
6
import json
7
+ import gc
10
8
from qgate_perf .file_format import FileFormat
11
9
from qgate_perf .run_setup import RunSetup
12
10
from qgate_perf .bundle_helper import BundleHelper
15
13
from qgate_perf .run_return import RunReturn
16
14
from platform import python_version
17
15
from packaging import version
18
- from qgate_graph .graph_performance import GraphPerformance
19
- from qgate_graph .graph_executor import GraphExecutor
20
16
from contextlib import suppress
21
17
22
18
@@ -69,7 +65,7 @@ def __init__(self,
69
65
70
66
def _coreThreadClassPool (self , threads , return_key , return_dict , run_setup : RunSetup ):
71
67
try :
72
- with ThreadPoolExecutor (max_workers = threads ) as executor :
68
+ with concurrent . futures . ThreadPoolExecutor (max_workers = threads ) as executor :
73
69
features = []
74
70
for threadKey in range (threads ):
75
71
run_return = RunReturn (f"{ return_key } x{ threadKey } " , return_dict )
@@ -114,7 +110,7 @@ def _coreThreadClassPool(self, threads, return_key, return_dict, run_setup: RunS
114
110
# t = None
115
111
#
116
112
# def _coreThreadPool(func, threads, return_key, return_dict, run_setup):
117
- # with ThreadPoolExecutor(max_workers=threads) as executor:
113
+ # with concurrent.futures. ThreadPoolExecutor(max_workers=threads) as executor:
118
114
# features = []
119
115
# for thread_key in range(threads):
120
116
# features.append(
@@ -253,18 +249,18 @@ def _executeCore(self, run_setup: RunSetup, return_dict, processes=2, threads=2)
253
249
if threads == 1 :
254
250
for process_key in range (processes ):
255
251
run_return = RunReturn (process_key , return_dict )
256
- p = Process (target = self ._func_wrapper ,
252
+ p = multiprocessing . Process (target = self ._func_wrapper ,
257
253
args = (self ._func , run_return , run_setup ))
258
254
# oldversion args=(process_key, return_dict, run_setup))
259
255
260
256
proc .append (p )
261
257
else :
262
258
for process_key in range (processes ):
263
- p = Process (target = self ._coreThreadClassPool ,
259
+ p = multiprocessing . Process (target = self ._coreThreadClassPool ,
264
260
args = (threads , process_key , return_dict , run_setup ))
265
- # p = Process( target=self._coreThreadClass, args=(threads, process_key, return_dict, run_setup))
266
- # p = Process(target=ParallelExecutor._coreThread, args=(self.func, threads, process_key, return_dict, run_setup))
267
- # p = Process(target=ParallelExecutor._coreThreadPool, args=(self.func, threads, process_key, return_dict, run_setup))
261
+ # p = multiprocessing. target=self._coreThreadClass, args=(threads, process_key, return_dict, run_setup))
262
+ # p = multiprocessing. Process(target=ParallelExecutor._coreThread, args=(self.func, threads, process_key, return_dict, run_setup))
263
+ # p = multiprocessing. Process(target=ParallelExecutor._coreThreadPool, args=(self.func, threads, process_key, return_dict, run_setup))
268
264
proc .append (p )
269
265
270
266
# start
@@ -479,6 +475,9 @@ def create_graph(self, output_graph_dir="output", picture_dpi=100, suppress_erro
479
475
:param suppress_error: suppress error (default is False)
480
476
:return: list of output files
481
477
"""
478
+ from qgate_graph .graph_performance import GraphPerformance
479
+ from qgate_graph .graph_executor import GraphExecutor
480
+
482
481
output_file = []
483
482
484
483
graph = GraphPerformance (picture_dpi )
@@ -499,6 +498,7 @@ def create_graph_perf(self, output_graph_dir="output", picture_dpi=100, suppress
499
498
:param suppress_error: suppress error (default is False)
500
499
:return: list of output files
501
500
"""
501
+ from qgate_graph .graph_performance import GraphPerformance
502
502
503
503
graph = GraphPerformance (picture_dpi )
504
504
return graph .generate_from_file (self ._output_file , os .path .join (output_graph_dir ,"graph-perf" ), suppress_error )
@@ -512,6 +512,7 @@ def create_graph_exec(self, output_graph_dir="output", picture_dpi=100, suppress
512
512
:param suppress_error: suppress error (default is False)
513
513
:return: list of output files
514
514
"""
515
+ from qgate_graph .graph_executor import GraphExecutor
515
516
516
517
graph = GraphExecutor (picture_dpi )
517
518
return graph .generate_from_file (self ._output_file ,os .path .join (output_graph_dir ,"graph-exec" ), suppress_error )
0 commit comments