import time import sys from threading import Thread def doBad(): int("as") def printSomething(): print "-i- I'm writing from SomeModule1" for i in [1,2,3,4,5,6]: time.sleep(1) print "-i- process "+ str(i) if i==4: Thread(target=doBad, name='stderr-watcher').start() sys.stdout.flush() def main(): printSomething() if __name__ == '__main__': main()