diff options
author | brian.quinlan <devnull@localhost> | 2010-05-22 08:34:17 +0000 |
---|---|---|
committer | brian.quinlan <devnull@localhost> | 2010-05-22 08:34:17 +0000 |
commit | 074931febfe36288d32cdde029a9bec11fbb3227 (patch) | |
tree | fb4b92b4fbae508019ce6be776fee7b6e586265d | |
parent | d704d8ed38d62df92b2221b1207acc61535b35c6 (diff) | |
download | futures-074931febfe36288d32cdde029a9bec11fbb3227.tar.gz |
Fixes examples for windows.
-rw-r--r-- | python3/crawl.py | 3 | ||||
-rw-r--r-- | python3/moprocessmoproblems.py | 59 | ||||
-rw-r--r-- | python3/primes.py | 3 |
3 files changed, 4 insertions, 61 deletions
diff --git a/python3/crawl.py b/python3/crawl.py index 96dfc67..7135682 100644 --- a/python3/crawl.py +++ b/python3/crawl.py @@ -64,4 +64,5 @@ def main(): len(url_map), len(URLS))) -main() +if __name__ == '__main__': + main() diff --git a/python3/moprocessmoproblems.py b/python3/moprocessmoproblems.py deleted file mode 100644 index 18bfc39..0000000 --- a/python3/moprocessmoproblems.py +++ /dev/null @@ -1,59 +0,0 @@ -import multiprocessing -import queue - -def _process_worker(q): - while True: - try: - something = q.get(block=True, timeout=0.1) - except queue.Empty: - return - else: - print('Grabbed item from queue:', something) - - -def _make_some_processes(q): - processes = [] - for _ in range(10): - p = multiprocessing.Process(target=_process_worker, args=(q,)) - p.start() - processes.append(p) - return processes - -def _do(i): - print('Run:', i) - q = multiprocessing.Queue() - print('Created queue') - for j in range(30): - q.put(i*30+j) - processes = _make_some_processes(q) - print('Created processes') - - while not q.empty(): - pass - print('Q is empty') - - # Without the two following commented lines, the output on Mac OS 10.5 (the - # output is as expected on Linux) will be: - # Run: 0 - # Created queue - # Grabbed item from queue: 0 - # ... - # Grabbed item from queue: 29 - # Created processes - # Q is empty - # Run: 1 - # Created queue - # Grabbed item from queue: 30 - # ... - # Grabbed item from queue: 59 - # Created processes - # Q is empty - # Run: 2 - # Created queue - # Created processes - # <no further output> -# for p in processes: -# p.join() - -for i in range(100): - _do(i)
\ No newline at end of file diff --git a/python3/primes.py b/python3/primes.py index 20b5202..5152fcb 100644 --- a/python3/primes.py +++ b/python3/primes.py @@ -43,4 +43,5 @@ def main(): else: print('%.2f seconds' % (time.time() - start)) -main()
\ No newline at end of file +if __name__ == '__main__': + main() |