Last active
August 29, 2015 14:14
-
-
Save yeondudad/e02fb2f023a373d21291 to your computer and use it in GitHub Desktop.
This file contains 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
from multiprocessing.pool import ThreadPool | |
from os import getpid | |
from time import sleep | |
def fn_sleep(s): | |
sleep(s) | |
return getpid() | |
sleep_time = [10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] | |
pool = ThreadPool() | |
async_results = [] | |
for s_ in sleep_time: | |
async_result = pool.apply_async(fn_sleep, kwds={'s': s_}) | |
async_results.append(async_result) | |
print [async_result.get() for async_result in async_results] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment