multiprocessing-logging
multiprocessing-logging copied to clipboard
How to use this module
Hi, I try to use this module according to the readme, but the logs seem to be messed like when I don't use this module. What I am doing wrong?
import logging
from multiprocessing import Pool
from multiprocessing_logging import install_mp_handler
import functions
import globals as g
# init logging
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', level=logging.INFO)
install_mp_handler()
# init multi processing pool
pool = Pool(g.args.parallel)
results = pool.map(functions.backup_image, [image for key, image in sorted(g.images.iteritems())])
pool.close()
and in functions.backup_image I use:
logging.info('Backup persistent image %d:%s attached to VM %d:%s as disk %d' % (
image.ID, image.NAME, vmId, vm.NAME, vmDiskId))
Which OS and Python version are you using?
OL7.9 and python 2.7.5
What is OL7.9?
Oracle Linux 7.9, same as CentOS 7.9 or RHEL 7.9
That's it. It should work. If you add a sleep after the close(), does it make a difference?
Hi, nothing changed. I also try log to file, but logs are mixed too
No idea.
probably problem of python 2.7? should I try python 3?
This module should work with either. If you can choose, I'd encourage you to always use Python 3.
Sorry, no idea what to do here. :(