There is a problem with receiving messages from the program registrar if this program is called with a subprocess.
Here's the BooFoo.py program that uses the log to print messages in a file and console window:
import logging
LOG_FILENAME = 'example.log'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)
logger = logging.getLogger('main')
logger.addHandler(logging.StreamHandler())
print 'print foo'
logger.info('logger boo')
Here's the CallBooFoo.py program:
import subprocess
proc = subprocess.Popen(['python BooFoo.py'], bufsize=512, stdin = None,
stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True)
proc_out, proc_err = proc.communicate()
print proc_out
"logger boo" is not printed using CallBooFoo.py. Any idea how to fix this? Using os.system works, but is not a solution for other reasons.
source
share