Skip to content

Instantly share code, notes, and snippets.

@keitheis
Last active August 27, 2016 04:43
Show Gist options
  • Save keitheis/b7ee858e8dfbe0c00b25b6dde9582476 to your computer and use it in GitHub Desktop.
Save keitheis/b7ee858e8dfbe0c00b25b6dde9582476 to your computer and use it in GitHub Desktop.
import alog
from threading import Thread
from multiprocessing import Process
def make_log(x):
def logging():
for i in range(5):
alog.info("loging {}:{}".format(x, i))
return logging
ts = []
for i in range(4):
t = Thread(None, make_log(i))
# t = Process(target=make_log(i))
ts.append(t)
for t in ts:
t.start()
💰 pyx t.py # threading
2016-08-27 12:42:10,693 INFO [t:10] loging 0:0
2016-08-27 12:42:10,693 INFO [t:10] loging 0:1
2016-08-27 12:42:10,693 INFO [t:10] loging 0:2
2016-08-27 12:42:10,693 INFO [t:10] loging 0:3
2016-08-27 12:42:10,694 INFO [t:10] loging 0:4
2016-08-27 12:42:10,694 INFO [t:10] loging 1:0
2016-08-27 12:42:10,694 INFO [t:10] loging 1:1
2016-08-27 12:42:10,694 INFO [t:10] loging 1:2
2016-08-27 12:42:10,694 INFO [t:10] loging 1:3
2016-08-27 12:42:10,694 INFO [t:10] loging 2:0
2016-08-27 12:42:10,694 INFO [t:10] loging 1:4
2016-08-27 12:42:10,694 INFO [t:10] loging 2:1
2016-08-27 12:42:10,695 INFO [t:10] loging 3:0
2016-08-27 12:42:10,695 INFO [t:10] loging 2:2
2016-08-27 12:42:10,695 INFO [t:10] loging 3:1
2016-08-27 12:42:10,695 INFO [t:10] loging 2:3
2016-08-27 12:42:10,695 INFO [t:10] loging 3:2
2016-08-27 12:42:10,695 INFO [t:10] loging 2:4
2016-08-27 12:42:10,695 INFO [t:10] loging 3:3
2016-08-27 12:42:10,696 INFO [t:10] loging 3:4
💰 pyx t.py # processes
2016-08-27 12:41:13,107 INFO [t:10] loging 0:0
2016-08-27 12:41:13,108 INFO [t:10] loging 0:1
2016-08-27 12:41:13,108 INFO [t:10] loging 1:0
2016-08-27 12:41:13,109 INFO [t:10] loging 0:2
2016-08-27 12:41:13,109 INFO [t:10] loging 0:3
2016-08-27 12:41:13,109 INFO [t:10] loging 1:1
2016-08-27 12:41:13,109 INFO [t:10] loging 0:4
2016-08-27 12:41:13,109 INFO [t:10] loging 1:2
2016-08-27 12:41:13,109 INFO [t:10] loging 1:3
2016-08-27 12:41:13,109 INFO [t:10] loging 1:4
2016-08-27 12:41:13,109 INFO [t:10] loging 2:0
2016-08-27 12:41:13,110 INFO [t:10] loging 2:1
2016-08-27 12:41:13,110 INFO [t:10] loging 2:2
2016-08-27 12:41:13,110 INFO [t:10] loging 2:3
2016-08-27 12:41:13,110 INFO [t:10] loging 2:4
2016-08-27 12:41:13,110 INFO [t:10] loging 3:0
2016-08-27 12:41:13,111 INFO [t:10] loging 3:1
2016-08-27 12:41:13,111 INFO [t:10] loging 3:2
2016-08-27 12:41:13,111 INFO [t:10] loging 3:3
2016-08-27 12:41:13,112 INFO [t:10] loging 3:4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment