Created
January 22, 2016 04:35
-
-
Save lxyu/1c1c15e57cde9e49dd17 to your computer and use it in GitHub Desktop.
Python daemon stdout flush demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import sys | |
import time | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
def handle(): | |
while True: | |
print("print - handle") | |
logging.info("logging - handle") | |
# sys.stdout.flush() | |
time.sleep(1) | |
def main(): | |
t = threading.Thread(target=handle) | |
t.setDaemon(True) | |
t.start() | |
time.sleep(10) | |
t.join(1) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment