September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -1,14 +1,8 @@
import random, sys, time
import threading
import random
lock = threading.Lock()
def echo(text):
print(text)
def echo(s):
time.sleep(1e-2*random.random())
# use `.write()` with lock due to `print` prints empty lines occasionally
with lock:
sys.stdout.write(s)
sys.stdout.write('\n')
for line in 'Enjoy Rosetta Code'.split():
threading.Thread(target=echo, args=(line,)).start()
for text in ["Enjoy", "Rosetta", "Code"]:
threading.Timer(random.random(), echo, (text,)).start()