From 16ec910ba55b0ff78d5647d59c532dc2a0580db1 Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Wed, 17 Sep 2014 14:03:20 +0200 Subject: [PATCH] Initialize logging only for multiprocessing --- headphones/music_encoder.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/headphones/music_encoder.py b/headphones/music_encoder.py index 9df0f129..46b0b9d6 100644 --- a/headphones/music_encoder.py +++ b/headphones/music_encoder.py @@ -228,11 +228,13 @@ def encode(albumPath): def command_map(args): """ - This method is used for the multiprocessing.map() method as a wrapper. + Wrapper for the '[multiprocessing.]map()' method, to unpack the arguments + and wrap exceptions. """ - # Reinitialize logger for multiprocessing - logger.initMultiprocessing() + # Initialize multiprocessing logger + if multiprocessing.current_process().name != "MainProcess": + logger.initMultiprocessing() # Start encoding try: @@ -242,8 +244,13 @@ def command_map(args): return False def command(encoder, musicSource, musicDest, albumPath): - cmd=[] - startMusicTime=time.time() + """ + Encode a given music file with a certain encoder. Returns True on success, + or False otherwise. + """ + + startMusicTime = time.time() + cmd = [] # XLD if XLD: