I'm burnt out, I can't get multithreaded audio feature extractor to work :(
This commit is contained in:
30
mtafe_lab/test_mp.py
Normal file
30
mtafe_lab/test_mp.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import logging
|
||||
logging.basicConfig(format="%(asctime)s/%(levelname)s: [%(module)s] %(message)s", level=logging.INFO)
|
||||
|
||||
import multiprocessing
|
||||
from dataset import random_audio_chunk
|
||||
import audiopreprocessing
|
||||
from time import sleep
|
||||
|
||||
origin_queue = multiprocessing.Queue()
|
||||
target_queue = multiprocessing.Queue()
|
||||
|
||||
def worker(orig, targ):
|
||||
p = orig.get()
|
||||
#out = "PROCESSED" + str(p.absolute())
|
||||
out = audiopreprocessing.load_preprocessed_audio(p, 16000, True) # This will cause put to hang
|
||||
targ.put(out) # This will hang the process
|
||||
|
||||
if __name__ == "__main__":
|
||||
K = 2
|
||||
|
||||
for p in random_audio_chunk(K):
|
||||
origin_queue.put(p)
|
||||
|
||||
processes = [multiprocessing.Process(target=worker, args=(origin_queue, target_queue)) for _ in range(K)]
|
||||
for p in processes: p.start()
|
||||
for p in processes: p.join()
|
||||
|
||||
logging.critical("Successfully terminated all threads")
|
||||
|
||||
for _ in range(K): print(target_queue.get())
|
||||
Reference in New Issue
Block a user