I'm trying to make my first Python package as a learning experience. There's a lot of things that I suspect I am doing poorly, but this post is specifically about my HttpRequest class. I made this class so that I can use retries and persistent session.
class HttpRequest:
__session = None
@staticmethod
def __init__session__():
if HttpRequest.__session is not None:
return
stderr.write("Initializing HTTPS Session\n")
HttpRequest.__session = HttpSession()
retries = Retry(total=3,
backoff_factor=1,
status_forcelist=[], # 429
allowed_methods=False)
HttpRequest.__session.mount("https://", HTTPAdapter(max_retries=retries))
@staticmethod
def get(url):
print(f"Querying {url}")
HttpRequest.__init__session__()
return HttpRequest.__session.get(url)
I use this class basically everywhere in the package, so I want to make sure I'm doing this well.