Skip to content

Instantly share code, notes, and snippets.

@lxyu
Created January 22, 2016 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lxyu/1c1c15e57cde9e49dd17 to your computer and use it in GitHub Desktop.
Save lxyu/1c1c15e57cde9e49dd17 to your computer and use it in GitHub Desktop.
Python daemon stdout flush demo
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