Add files via upload
This commit is contained in:
Binary file not shown.
+66
-7
@@ -5,17 +5,50 @@
|
|||||||
import keywords
|
import keywords
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import multiprocessing as mp
|
import multiprocessing
|
||||||
|
import threading
|
||||||
|
|
||||||
keywords.init()
|
keywords.init()
|
||||||
num_cores = mp.cpu_count()
|
num_cores = multiprocessing.cpu_count()
|
||||||
|
work_queue = multiprocessing.JoinableQueue()
|
||||||
|
signal_queue = multiprocessing.JoinableQueue()
|
||||||
|
|
||||||
test_folder = ""
|
test_folder = "..\\gtk"
|
||||||
|
print(test_folder)
|
||||||
filelist = []
|
filelist = []
|
||||||
|
processes = []
|
||||||
|
threads = []
|
||||||
|
|
||||||
|
class Listener:
|
||||||
|
def __init__(self, queue):
|
||||||
|
self.signal_queue = queue
|
||||||
|
|
||||||
|
def go(self):
|
||||||
|
print("Listener has started")
|
||||||
|
while True:
|
||||||
|
# Listen for results on the queue and process them accordingly
|
||||||
|
data = self.signal_queue.get()
|
||||||
|
print(data)
|
||||||
|
# Check if finished
|
||||||
|
if data[0]=="work_update":
|
||||||
|
print("Workers are working.")
|
||||||
|
return
|
||||||
|
|
||||||
|
class Worker:
|
||||||
|
def __init__(self, sq, wq):
|
||||||
|
self.signal_queue = sq
|
||||||
|
self.work_queue = wq
|
||||||
|
|
||||||
|
def go(self):
|
||||||
|
while True:
|
||||||
|
print("Working")
|
||||||
|
task = self.work_queue.get(2)
|
||||||
|
print(task)
|
||||||
|
time.sleep(0.001)
|
||||||
|
self.work_queue.task_done()
|
||||||
|
self.signal_queue.put("work_update")
|
||||||
|
self.work_queue.task_done()
|
||||||
|
|
||||||
class worker:
|
|
||||||
|
|
||||||
|
|
||||||
class parser:
|
class parser:
|
||||||
def __init__(self, file):
|
def __init__(self, file):
|
||||||
self.prep = keywords.preprocessor_directives
|
self.prep = keywords.preprocessor_directives
|
||||||
@@ -143,7 +176,33 @@ def process_file(data):
|
|||||||
newfile.write(outfile)
|
newfile.write(outfile)
|
||||||
newfile.close()
|
newfile.close()
|
||||||
|
|
||||||
test_folder = get_script_path()
|
test_folder = get_script_path()+'\\..\\gtk'
|
||||||
print(test_folder)
|
print(test_folder)
|
||||||
print('Number of *.h files in directory: ',sourcedir_filecnt(test_folder))
|
print('Number of *.h files in directory: ',sourcedir_filecnt(test_folder))
|
||||||
print(num_cores)
|
print(num_cores)
|
||||||
|
|
||||||
|
print("Creating Listener")
|
||||||
|
listener = Listener(signal_queue)
|
||||||
|
|
||||||
|
print("Starting Listener")
|
||||||
|
thread = threading.Thread(target=listener.go, args=())
|
||||||
|
thread.start()
|
||||||
|
threads.append(thread)
|
||||||
|
print(threads)
|
||||||
|
|
||||||
|
print("Creating work queue")
|
||||||
|
for i in filelist:
|
||||||
|
work_queue.put(i)
|
||||||
|
print(work_queue.qsize())
|
||||||
|
|
||||||
|
for i in range(num_cores):
|
||||||
|
w = Worker(signal_queue, work_queue)
|
||||||
|
p = multiprocessing.Process(target = w.go, args=())
|
||||||
|
p.deamon = True
|
||||||
|
p.start()
|
||||||
|
processes.append(p)
|
||||||
|
print(processes)
|
||||||
|
|
||||||
|
work_queue.join()
|
||||||
|
for i in range(num_cores):
|
||||||
|
work_queue.put(None)
|
||||||
Reference in New Issue
Block a user