Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multithreading
#1
This script is supposed to download images in multithreading processes.
#! python3
# multidx.py - Downloads XKCD comics using multiple threads.

import requests, os, bs4, threading

os.makedirs('xkcd', exist_ok=True)   # store comics in ./xkcd

def downloadXkcd(startComic, endComic):
	for urlNumber in range(startComic, endComic + 1):
		print(f'Downloading page http://xkcd.com/{urlNumber}...')
		res = requests.get(f'http://xkcd.com/{urlNumber}')
		res.raise_for_status()
		soup = bs4.BeautifulSoup(res.text)
		comicElem = soup.select('#comic img')
		if comicElem == []:
			print('Could not find comic image.')
		else:
			comicUrl = comicElem[0].get('src')
			print(f'Downloading image {comicUrl}')
			res = requests.get(comicUrl)
			res.raise_for_status()
			imageFile = open(os.path.join('xkcd', os.path.basename(comicUrl)), 'wb')
			for chunk in res.iter_content(100000):
				imageFile.write(chunk)
			imageFile.close()
			
downloadThreads = []             # a list of all Thread objects
for i in range(0, 1400, 100):    # loops 14 times, creates 14 threads
	downloadThread = threading.Thread(target=downloadXkcd, args(i, i + 99))
	downloadThreads.append(downloadThread)
	downloadThread.start()

# Wait for all threads to end
for downloadThread in downloadThreads:
	downloadThread.join()
print('Done.')
but I receive an error
Error:
C:\Python36\kodovi>multidx.py File "C:\Python36\kodovi\multidx.py", line 29 downloadThread = threading.Thread(target=downloadXkcd, args(i, i + 99)) ^ SyntaxError: positional argument follows keyword argument
I thought that the keyword argument goes first and then positional.

Also, I would appreciate if anyone could explain me the last chunk of code. Why calling a Thread object’s join() method will block until that thread has finished? The assumption is that there’s some code you don’t want to run in the main thread until all the threads have completed.
Quote
#2
For function arguments, the order always positional args, keyword args, and keyword-only args. The reason for this is that keyword arguments can be assigned as position arguments.

def test(var1=0, var2=0):
	return var1 + var2

test(4, 5) # Returns 9
In order to do that, the order of the keyword arguments must be maintained as long as positional arguments are provided. If we were to do test(var2=3, 4), the interpreter would be attempting to assign var2 twice which means that var1 isn't assigned. In this case, that wouldn't be the end of the world since var1 has a default value, but if it were a positional argument, that would be a problem.

The Thread.join() method runs a loop that repeatedly checks the status of the active Thread object. If the Thread is still alive - meaning that its Thread.run() has not returned - then the loop continues. It does two primary things:

  1. By halting execution of the main thread, it prevents code which may be dependent on the tasks in the thread from running. If such code were to run, it would encounter errors.
  2. It also prevents the main thread from completing. If the main thread were to complete, the program would exit. The Threads would still be running as zombies in the because they are independent of the main thread. Halting the main thread enables you to get feedback on the status of the other Threads.
Truman likes this post
Quote
#3
At least, expected = in line 29: args = (i, i + 99)
Truman likes this post
Quote
#4
after changing the line to downloadThread = threading.Thread(args=(i, i + 99), target=downloadXkcd) a looong message appears ( you don't have to bother with that if it causes you anxiety! ):
Error:
return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 383, in prepare_ url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/religions .png': No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comics/relig ions.png? Downloading image //imgs.xkcd.com/comics/facebook.png Exception in thread Thread-4: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get(comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 383, in prepare_ url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/facebook. png': No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comics/facebo ok.png? Downloading image //imgs.xkcd.com/comics/beautiful_dream.png Exception in thread Thread-9: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get(comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 383, in prepare_ url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/beautiful _dream.png': No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comics /beautiful_dream.png? Downloading image //imgs.xkcd.com/comics/1000_comics.png Exception in thread Thread-11: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get(comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 383, in prepare_ url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/1000_comi cs.png': No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comics/100 0_comics.png? Downloading image //imgs.xkcd.com/comics/galilean_moons.png Exception in thread Thread-14: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get(comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 383, in prepare_ url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/galilean_ moons.png': No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comics/ galilean_moons.png? Downloading image //imgs.xkcd.com/comics/android_boyfriend.png Exception in thread Thread-7: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get(comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 383, in prepare_ url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/android_b oyfriend.png': No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comi cs/android_boyfriend.png? Downloading image //imgs.xkcd.com/comics/family_circus.jpg Exception in thread Thread-2: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get(comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 383, in prepare_ url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/family_ci rcus.jpg': No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comics/f amily_circus.jpg? Downloading image //imgs.xkcd.com/comics/election.png Exception in thread Thread-6: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get(comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 383, in prepare_ url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/election. png': No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comics/electi on.png? Downloading image //imgs.xkcd.com/comics/vows.png Exception in thread Thread-12: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get(comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 383, in prepare_ url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/vows.png' : No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comics/vows.png? Downloading image //imgs.xkcd.com/comics/complexion.png Exception in thread Thread-8: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get(comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 383, in prepare_ url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/complexio n.png': No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comics/comp lexion.png? Downloading image //imgs.xkcd.com/comics/important_life_lesson.png Exception in thread Thread-5: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get(comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 383, in prepare_ url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/important _life_lesson.png': No schema supplied. Perhaps you meant http:////imgs.xkcd.com/ comics/important_life_lesson.png? Done.
Quote
#5
The important part of that traceback is:

Error:
requests.exceptions.MissingSchema: Invalid URL '//imgs.xkcd.com/comics/vows.png' : No schema supplied. Perhaps you meant http:////imgs.xkcd.com/comics/vows.png?
In downloadXKCD(), you have

comicUrl = comicElem[0].get('src')
print(f'Downloading image {comicUrl}')
res = requests.get(comicUrl)
and the traceback is indicating that comicUrl, which is passed into requests.get(), does not have a schema at the beginning. In HTML coding, it is good practice to use relative paths for URIs instead of absolute paths. As such, the beginning of the image URI is missing. You'll need to prepend "http://" to the beginning of the URI. This should work:

comicUrl = comicElem[0].get('src')
print(f'Downloading image {comicUrl}')
res = requests.get("http://" + comicUrl)
Quote
#6
Thank you, now I get
Error:
File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get("http://" + comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 386, in prepare_ url raise InvalidURL("Invalid URL %r: No host supplied" % url) requests.exceptions.InvalidURL: Invalid URL 'http:////imgs.xkcd.com/comics/relig ions.png': No host supplied Downloading image //imgs.xkcd.com/comics/android_boyfriend.png Exception in thread Thread-7: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get("http://" + comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 386, in prepare_ url raise InvalidURL("Invalid URL %r: No host supplied" % url) requests.exceptions.InvalidURL: Invalid URL 'http:////imgs.xkcd.com/comics/andro id_boyfriend.png': No host supplied Downloading image //imgs.xkcd.com/comics/beautiful_dream.png Exception in thread Thread-9: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get("http://" + comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 386, in prepare_ url raise InvalidURL("Invalid URL %r: No host supplied" % url) requests.exceptions.InvalidURL: Invalid URL 'http:////imgs.xkcd.com/comics/beaut iful_dream.png': No host supplied Downloading image //imgs.xkcd.com/comics/important_life_lesson.png Exception in thread Thread-5: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get("http://" + comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 386, in prepare_ url raise InvalidURL("Invalid URL %r: No host supplied" % url) requests.exceptions.InvalidURL: Invalid URL 'http:////imgs.xkcd.com/comics/impor tant_life_lesson.png': No host supplied Downloading image //imgs.xkcd.com/comics/facebook.png Exception in thread Thread-4: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get("http://" + comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 386, in prepare_ url raise InvalidURL("Invalid URL %r: No host supplied" % url) requests.exceptions.InvalidURL: Invalid URL 'http:////imgs.xkcd.com/comics/faceb ook.png': No host supplied Downloading image //imgs.xkcd.com/comics/galilean_moons.png Downloading image //imgs.xkcd.com/comics/authorization.png Exception in thread Thread-14: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get("http://" + comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 386, in prepare_ url raise InvalidURL("Invalid URL %r: No host supplied" % url) requests.exceptions.InvalidURL: Invalid URL 'http:////imgs.xkcd.com/comics/galil ean_moons.png': No host supplied Exception in thread Thread-13: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get("http://" + comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 386, in prepare_ url raise InvalidURL("Invalid URL %r: No host supplied" % url) requests.exceptions.InvalidURL: Invalid URL 'http:////imgs.xkcd.com/comics/autho rization.png': No host supplied Downloading image //imgs.xkcd.com/comics/election.png Exception in thread Thread-6: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get("http://" + comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 386, in prepare_ url raise InvalidURL("Invalid URL %r: No host supplied" % url) requests.exceptions.InvalidURL: Invalid URL 'http:////imgs.xkcd.com/comics/elect ion.png': No host supplied Downloading image //imgs.xkcd.com/comics/family_circus.jpg Exception in thread Thread-2: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get("http://" + comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 386, in prepare_ url raise InvalidURL("Invalid URL %r: No host supplied" % url) requests.exceptions.InvalidURL: Invalid URL 'http:////imgs.xkcd.com/comics/famil y_circus.jpg': No host supplied Downloading image //imgs.xkcd.com/comics/bill_nye.png Downloading image //imgs.xkcd.com/comics/1000_comics.png Exception in thread Thread-11: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get("http://" + comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 386, in prepare_ url raise InvalidURL("Invalid URL %r: No host supplied" % url) requests.exceptions.InvalidURL: Invalid URL 'http:////imgs.xkcd.com/comics/1000_ comics.png': No host supplied Exception in thread Thread-3: Traceback (most recent call last): File "C:\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Python36\kodovi\multidx.py", line 20, in downloadXkcd res = requests.get("http://" + comicUrl) File "C:\Python36\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, **kwargs) File "C:\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Python36\lib\site-packages\requests\sessions.py", line 498, in reques t prep = self.prepare_request(req) File "C:\Python36\lib\site-packages\requests\sessions.py", line 441, in prepar e_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Python36\lib\site-packages\requests\models.py", line 309, in prepare self.prepare_url(url, params) File "C:\Python36\lib\site-packages\requests\models.py", line 386, in prepare_ url raise InvalidURL("Invalid URL %r: No host supplied" % url) requests.exceptions.InvalidURL: Invalid URL 'http:////imgs.xkcd.com/comics/bill_ nye.png': No host supplied Done.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Queue get memory leak when used in multithreading wangcp 1 181 Nov-27-2018, 04:06 AM
Last Post: wangcp
  Multithreading with queues - code optimization h1v3s3c 1 477 May-10-2018, 10:40 AM
Last Post: ThiefOfTime
  How to reallocating memory space in multithreading program in python ? siva 2 650 Mar-08-2018, 03:49 AM
Last Post: siva
  Another working code, help required for faster multithreading execution anna 0 462 Feb-09-2018, 03:26 AM
Last Post: anna
  Multithreading in a loop valtih 3 4,713 Aug-03-2017, 08:20 PM
Last Post: valtih
  Multithreading with ssh connection harusin 6 1,543 Jul-10-2017, 11:40 AM
Last Post: harusin
  Multithreading socket in Python. I'm missing something Guybrush 1 1,172 Apr-28-2017, 11:14 PM
Last Post: Ofnuts

Forum Jump:


Users browsing this thread: 1 Guest(s)