Вот очень простой пример того, о чем, я думаю, вы просили.И да, как говорит RestRisiko, urllib2
является поточно-ориентированным, если это фактически все, о чем вы просите.
import threading
import urllib2
from time import sleep
def load_img(local_path, web_path):
f = open(local_path, 'wb')
f.write(urllib2.urlopen(web_path).read())
f.close()
local_path = 'foo.txt'
web_path = 'http://www.google.com/'
img_thread = threading.Thread(target=load_img, args=(local_path, web_path))
img_thread.start()
while img_thread.is_alive():
print "doing some other stuff while the thread does its thing"
sleep(1)
img_thread.join()