Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
multithread_logging.py
import sys
import logging
from multiprocessing.pool import Pool
logging.basicConfig(stream=sys.stdout, level=logging.INFO,
format='%(asctime)s - %(processName)s %(threadName)s - %(name)s - %(levelname)s - %(message)s')
if __name__ == "__main__":
def job(name):
logger = logging.getLogger(name)
logger.info("balabala")
size = 5
pool = Pool(size)
futures = [pool.apply_async(job, args=('Job-%d' % i, )) for i in range(size)]
[f.get() for f in futures]
pool.close()
pool.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.