Created
August 10, 2014 06:53
-
-
Save sanfx/cffed1fd0b811180d4ed 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
| You can write the threaded example as: | |
| import concurrent.futures | |
| import itertools | |
| import random | |
| def generate_random(count): | |
| return [random.random() for _ in range(count)] | |
| if __name__ == "__main__": | |
| with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: | |
| executor.submit(generate_random, 10000000) | |
| executor.submit(generate_random, 10000000) | |
| # I guess we don't care about the results... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment