mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-18 18:01:24 +02:00
global timeout
This commit is contained in:
parent
0583c7910c
commit
7152ec2e1a
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user