multiprocessing-logging icon indicating copy to clipboard operation
multiprocessing-logging copied to clipboard

How to use this module

Open feldsam opened this issue 4 years ago • 9 comments
trafficstars

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))

feldsam avatar Dec 28 '20 13:12 feldsam

Which OS and Python version are you using?

jruere avatar Dec 28 '20 13:12 jruere

OL7.9 and python 2.7.5

feldsam avatar Dec 28 '20 14:12 feldsam

What is OL7.9?

jruere avatar Dec 28 '20 19:12 jruere

Oracle Linux 7.9, same as CentOS 7.9 or RHEL 7.9

feldsam avatar Dec 28 '20 22:12 feldsam

That's it. It should work. If you add a sleep after the close(), does it make a difference?

jruere avatar Dec 29 '20 02:12 jruere

Hi, nothing changed. I also try log to file, but logs are mixed too

feldsam avatar Dec 30 '20 11:12 feldsam

No idea.

jruere avatar Dec 30 '20 15:12 jruere

probably problem of python 2.7? should I try python 3?

feldsam avatar Dec 30 '20 15:12 feldsam

This module should work with either. If you can choose, I'd encourage you to always use Python 3.

jruere avatar Dec 30 '20 15:12 jruere

Sorry, no idea what to do here. :(

jruere avatar Dec 20 '22 06:12 jruere