mirror of
				https://github.com/RicterZ/nhentai.git
				synced 2025-11-04 11:00:55 +01:00 
			
		
		
		
	global timeout
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
#coding: utf-8
 | 
			
		||||
import os
 | 
			
		||||
import sys
 | 
			
		||||
import socket
 | 
			
		||||
import threading
 | 
			
		||||
import Queue
 | 
			
		||||
import requests
 | 
			
		||||
@@ -8,6 +9,11 @@ from urlparse import urlparse
 | 
			
		||||
from hentai.logger import logger
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# global timeout
 | 
			
		||||
timeout = 30
 | 
			
		||||
socket.setdefaulttimeout(timeout)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Downloader(object):
 | 
			
		||||
    _instance = None
 | 
			
		||||
 | 
			
		||||
@@ -34,7 +40,7 @@ class Downloader(object):
 | 
			
		||||
        filename = filename if filename else os.path.basename(urlparse(url).path)
 | 
			
		||||
        try:
 | 
			
		||||
            with open(os.path.join(folder, filename), "wb") as f:
 | 
			
		||||
                response = requests.get(url, stream=True)
 | 
			
		||||
                response = requests.get(url, stream=True, timeout=10)
 | 
			
		||||
                length = response.headers.get('content-length')
 | 
			
		||||
                if length is None:
 | 
			
		||||
                    f.write(response.content)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user