Created
November 17, 2020 15:50
-
-
Save deeso/047b41e87f373c259c4a2a4241051ae6 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
from multiprocessing import Process | |
import pycurl | |
from io import BytesIO | |
URLS = [ | |
"https://releases.ubuntu.com/20.04.1/ubuntu-20.04.1-desktop-amd64.iso", | |
"https://repo.ialab.dsu.edu/ubuntu-releases/20.04.1/ubuntu-20.04.1-desktop-amd64.iso", | |
"http://ubuntu.osuosl.org/releases/20.04.1/ubuntu-20.04.1-desktop-amd64.iso", | |
"http://mirror.cs.jmu.edu/pub/ubuntu-iso/20.04.1/ubuntu-20.04.1-desktop-amd64.iso", | |
"http://mirror.metrocast.net/ubuntu-releases/focal/ubuntu-20.04.1-desktop-amd64.iso", | |
"http://ubuntu.cs.utah.edu/releases/20.04.1/ubuntu-20.04.1-desktop-amd64.iso", | |
] | |
def get_url(url): | |
while True: | |
crl = pycurl.Curl() | |
bo = open('/dev/null', 'wb') | |
crl.setopt(crl.WRITEFUNCTION, bo.write) | |
crl.setopt(crl.URL, url) | |
# crl.setopt(crl.WRITEDATA, bo) | |
crl.perform() | |
crl.close() | |
bo.close() | |
def do_work(): | |
processes = [] | |
for url in URLS: | |
p = Process(target=get_url, args=(url,)) | |
p.start() | |
processes.append(p) | |
p = Process(target=get_url, args=(url,)) | |
p.start() | |
processes.append(p) | |
for p in processes: | |
p.join() | |
if __name__ == "__name__": | |
do_work() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment