Created
February 7, 2014 21:37
-
-
Save ozkatz/8872402 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
import urllib2 | |
import multiprocessing | |
import sqlite3 | |
# With this line in place, calling urlopen() below | |
# will simply hang on OSX 10.9.1 (Python 2.7.5) | |
# comment the line out and urlopen() works as it should. | |
c = sqlite3.connect('/tmp/some.db') | |
def some_process(x): | |
print('about to open URL...') | |
res = urllib2.urlopen('http://www.google.com', timeout=3) | |
print('URL opened, reading lines...') | |
data = res.read() | |
print(data) | |
def run_pool(): | |
p = multiprocessing.Pool(3) | |
p.map(some_process, range(0, 50)) | |
if __name__ == '__main__': | |
run_pool() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment