Skip to content

Commit

Permalink
Merge pull request #248 from ArtrenH/main
Browse files Browse the repository at this point in the history
2023-11-27
  • Loading branch information
Belissimo-T authored Nov 27, 2023
2 parents 6c76c5b + a9a6ef4 commit dd55d0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions backend/load_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ async def main():
argument_parser.add_argument("--never-raise-out-of-proxies", action="store_true",
help="Never crash the program if no more proxies seem to be available. "
"Keep trying instead.")
argument_parser.add_argument("-interval", "-i", type=int, default=60,
help="Interval in seconds between each download cycle.")
argument_parser.add_argument("-loglevel", "-l", default="INFO")

args = argument_parser.parse_args()
Expand Down Expand Up @@ -164,12 +166,14 @@ async def main():
)
else:
await asyncio.gather(
*[crawler.plan_downloader.check_infinite(ignore_exceptions=args.ignore_exceptions)
*[crawler.plan_downloader.check_infinite(ignore_exceptions=args.ignore_exceptions,
interval=args.interval)
for crawler in crawlers.values()]
)
else:
await asyncio.gather(
*[crawler.check_infinite(once=args.once, ignore_exceptions=args.ignore_exceptions)
*[crawler.check_infinite(once=args.once, ignore_exceptions=args.ignore_exceptions,
interval=args.interval)
for crawler in crawlers.values()]
)
finally:
Expand Down
10 changes: 8 additions & 2 deletions shared/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,18 @@ async def send_message_async(message: Message) -> Message | None:

data = _serialize(message)

url = urllib3.util.Url(scheme="http", host="localhost", port=str(_PORT))
url = urllib3.util.Url(scheme="http", host="localhost", port=_PORT)

async with session.post(str(url), data=data, timeout=5) as response:
return _deserialize(await response.content.read())
except aiohttp.ClientConnectorError as e:
if e.errno == 111:
logging.getLogger("comm").warning(f"Error while sending message. Error: {str(e)}")
return None
else:
raise
except Exception as e:
logging.getLogger("comm").exception("Error while sending message.", exc_info=e)
logging.getLogger("comm").error("Error while sending message.", exc_info=e)
return None


Expand Down

0 comments on commit dd55d0b

Please sign in to comment.