I am creating a multiprocessor program for processing several batches, but my log cannot write a packet to a log file, only root log.info will be written, how can I configure logging to print correctly to a log file?
The line will be printed in the log "INFO: root: this is the root log"
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):
logging.info('this is sub logging' + str(batch))
return batch
if __name__ == '__main__':
process_batchs()
works on windows / python2.7
source
share