return parser
-def fetch(url: str, timeout: int) -> None:
- with requests.session() as s:
- with s.get(url, timeout=timeout) as r:
- r.raise_for_status()
+def fetch(url: str, session: requests.Session, timeout: int) -> None:
+ with session.get(url, timeout=timeout) as r:
+ r.raise_for_status()
def main() -> None:
args = command_line_parser().parse_args()
- fetch(args.url, args.timeout)
+ with requests.session() as session:
+ fetch(args.url, session, args.timeout)
if __name__ == '__main__':