Skip to content

Commit b105a4f

Browse files
committed
handle ConnectError
1 parent 8b432ba commit b105a4f

File tree

1 file changed

+6
-1
lines changed
  • pipelines/datasets/br_cnj_improbidade_administrativa

1 file changed

+6
-1
lines changed

pipelines/datasets/br_cnj_improbidade_administrativa/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import re
33
import typing
4+
import time
45

56
import httpx
67
from lxml import html
@@ -30,7 +31,11 @@ async def get_async(client: httpx.AsyncClient, url: str) -> httpx.Response:
3031
headers = {
3132
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
3233
}
33-
return await client.get(url, headers=headers)
34+
try:
35+
return await client.get(url, headers=headers)
36+
except httpx.ConnectError:
37+
time.sleep(10.0)
38+
return await client.get(url, headers=headers)
3439

3540

3641
class PeopleLine(typing.TypedDict):

0 commit comments

Comments
 (0)