import csv
import os
import shutil
from os import getenv
import pandas as pd
from mfg_core import *
from multiprocessing import JoinableQueue, Process
def producer(q):
for root, dirs, files in os.walk("work", topdown=False):
for name in files:
file = os.path.join(root, name)
logger.info(f'生产了一个file: {name}')
q.put(file)
q.join()
def consumer(q):
while True:
file = q.get()
logger.info(f'获得了一个file: {file}')
q.task_done()
logger = logging.getLogger(__name__)
if __name__ == '__main__':
jq = JoinableQueue()
p = Process(target=producer, args=(jq,))
p.start()
for i in range(7):
c = Process(target=consumer, args=(jq,))
c.daemon = True
c.start()
p.join()