Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Here is a straightforward way to capture the standard and error outputs from a custom process you are running. Back-linking to http://stackoverflow.com/a/23937468/472876

View myprocess.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
from multiprocessing import Process
import os
import sys
 
class MyProc(Process):
def run(self):
# Define the logging in run(), MyProc's entry function when it is .start()-ed
# p = MyProc()
# p.start()
self.initialize_logging()
 
print 'Now output is captured.'
 
# Now do stuff...
 
def initialize_logging(self):
sys.stdout = open(str(os.getpid()) + ".out", "a", buffering=0)
sys.stderr = open(str(os.getpid()) + "_error.out", "a", buffering=0)
 
print 'stdout initialized'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.