-
Notifications
You must be signed in to change notification settings - Fork 1
/
working_mp.py
48 lines (39 loc) · 985 Bytes
/
working_mp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import multiprocessing as mp
import glob
import os
def f(x):
files_sent=[]
count=0
new = 0
while True:
latest_file = max(glob.glob(x+"/*"), key=os.path.getctime)
count +=1
print(count)
if len(files_sent)<100:
# print("files_sent:"+str(len(files_sent)))
if str(latest_file) not in files_sent:
files_sent.append(str(latest_file))
f.q.put(latest_file) #put latest files in a queue for FRAMER
else:
print(2)
pass
else:
files_sent=[]
print(3)
# pass
def f_init(q):
f.q = q
def main(path_to_rec):
jobs = glob.glob(os.path.join(path_to_rec+"/*"))
q = mp.Queue()
p = mp.Pool(None, f_init, [q])
results = p.imap(f, jobs)
# p.join()
# p.close()
for i in range(len(jobs)):
print(q.get())
# print(results.next())
# [print(i) for i in results]
if __name__ == '__main__':
path_to_rec = "/mnt/f/IISc_Big/recordings/"
main(path_to_rec)