Skip to content

Instantly share code, notes, and snippets.

@ozkatz
Created February 7, 2014 21:37
Show Gist options
  • Save ozkatz/8872402 to your computer and use it in GitHub Desktop.
Save ozkatz/8872402 to your computer and use it in GitHub Desktop.
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