소스 검색

Handle struct.error from GzipFile.read() (Python bug?)

tags/v0.2
Ben Kurtovic 10 년 전
부모
커밋
f10908e34e
1개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. +5
    -4
      earwigbot/wiki/copyvios/workers.py

+ 5
- 4
earwigbot/wiki/copyvios/workers.py 파일 보기

@@ -25,8 +25,9 @@ from gzip import GzipFile
from logging import getLogger
from math import log
from Queue import Empty, Queue
from socket import error
from socket import error as socket_error
from StringIO import StringIO
from struct import error as struct_error
from threading import Lock, Thread
from time import time
from urllib2 import build_opener, URLError
@@ -125,7 +126,7 @@ class _CopyvioWorker(object):
url = source.url.encode("utf8")
try:
response = self._opener.open(url, timeout=source.timeout)
except (URLError, error):
except (URLError, socket_error):
return None

try:
@@ -146,7 +147,7 @@ class _CopyvioWorker(object):

try:
content = response.read()
except (URLError, error):
except (URLError, socket_error):
return None

if response.headers.get("Content-Encoding") == "gzip":
@@ -154,7 +155,7 @@ class _CopyvioWorker(object):
gzipper = GzipFile(fileobj=stream)
try:
content = gzipper.read(2 * 1024 ** 2)
except IOError:
except (IOError, struct_error):
return None

return handler(content)


불러오는 중...
취소
저장