Created
February 23, 2017 13:37
-
-
Save chaudum/70033077b380a69562b8dfc0e59b0615 to your computer and use it in GitHub Desktop.
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
# vi: set fileencoding=utf-8 | |
# -*- coding: utf-8; -*- | |
import threading | |
import argparse | |
import time | |
def parse_args(): | |
parser = argparse.ArgumentParser(description='') | |
return parser.parse_args() | |
def long_task(x): | |
print(x, ' start') | |
time.sleep(10) | |
print(x, ' end') | |
def main(): | |
ns = parse_args() | |
print(ns) | |
start = time.time() | |
threads = [] | |
for x in range(3): | |
t = threading.Thread(target=long_task, args=(x,)) | |
t.start() | |
threads.append(t) | |
[t.join() for t in threads] | |
print('done in ', time.time() - start, ' ms') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment