ProcessPoolExecutor logging failed?

Viewed 2165

I'm creating a multi-processing program to process multiple batches, but my logging is unable to record the batch into log file, only root log.info will be recorded, how can set logging to properly print to log file?

The log will only print such a line "INFO:root:this is root logging "

import logging
import concurrent.futures
def process_batchs():
    batches = [i for i in range(100)]
    logging.basicConfig(filename=r'doc\test_ProcessPoolExecutor.log', filemode='w+',level=logging.DEBUG)
    logging.info('this is root logging')
    with concurrent.futures.ProcessPoolExecutor(10) as e:
        futures = []
        for batch in batches:
            future = e.submit(f, batch)
            futures.append(future)
        while True:
            dones = [future.done() for future in futures]
            if all(dones):
               results = [future.result() for future in futures]
               print results
               break
def f(batch):
    # do some thing
    logging.info('this is sub logging' + str(batch))
    return batch


if __name__ == '__main__':
    process_batchs()

running on windows/python2.7

1 Answers
Related