Integrate httpx exceptions

This commit is contained in:
taizan-hokouto
2020-10-26 23:39:33 +09:00
parent 90596be880
commit 499cf26fa8
4 changed files with 5 additions and 7 deletions

View File

@@ -249,7 +249,7 @@ class LiveChatAsync:
resp = await client.get(url, headers=headers) resp = await client.get(url, headers=headers)
livechat_json = resp.json() livechat_json = resp.json()
break break
except (httpx.HTTPError, json.JSONDecodeError): except (json.JSONDecodeError, httpx.HTTPError):
await asyncio.sleep(1) await asyncio.sleep(1)
continue continue
else: else:

View File

@@ -241,7 +241,7 @@ class LiveChat:
try: try:
livechat_json = client.get(url, headers=headers).json() livechat_json = client.get(url, headers=headers).json()
break break
except (json.JSONDecodeError, httpx.TimeoutError): except (json.JSONDecodeError, httpx.HTTPError):
time.sleep(2) time.sleep(2)
continue continue
else: else:

View File

@@ -9,7 +9,6 @@ from ... import config
from ... paramgen import arcparam from ... paramgen import arcparam
from ... exceptions import UnknownConnectionError from ... exceptions import UnknownConnectionError
from concurrent.futures import CancelledError from concurrent.futures import CancelledError
from httpx import NetworkError, TimeoutException, ConnectError
from json import JSONDecodeError from json import JSONDecodeError
from urllib.parse import quote from urllib.parse import quote
@@ -81,7 +80,7 @@ def ready_blocks(video_id, duration, div, callback):
break break
except JSONDecodeError: except JSONDecodeError:
await asyncio.sleep(3) await asyncio.sleep(3)
except (NetworkError, TimeoutException, ConnectError) as e: except httpx.HTTPError as e:
err = e err = e
await asyncio.sleep(3) await asyncio.sleep(3)
else: else:
@@ -137,7 +136,7 @@ def fetch_patch(callback, blocks, video_id):
break break
except JSONDecodeError: except JSONDecodeError:
await asyncio.sleep(3) await asyncio.sleep(3)
except (NetworkError, TimeoutException, ConnectError) as e: except httpx.HTTPError as e:
err = e err = e
await asyncio.sleep(3) await asyncio.sleep(3)
except socket.error as error: except socket.error as error:

View File

@@ -2,7 +2,6 @@ import httpx
import json import json
import re import re
import time import time
from httpx import ConnectError, NetworkError, TimeoutException
from .. import config from .. import config
from ..exceptions import InvalidVideoIdException, PatternUnmatchError, UnknownConnectionError from ..exceptions import InvalidVideoIdException, PatternUnmatchError, UnknownConnectionError
from ..util.extract_video_id import extract_video_id from ..util.extract_video_id import extract_video_id
@@ -107,7 +106,7 @@ class VideoInfo:
resp = httpx.get(url, headers=headers) resp = httpx.get(url, headers=headers)
resp.raise_for_status() resp.raise_for_status()
break break
except (ConnectError, NetworkError, TimeoutException) as e: except httpx.HTTPError as e:
err = e err = e
time.sleep(3) time.sleep(3)
else: else: