Skip to content

Commit

Permalink
move _version_check() call outside class definition
Browse files Browse the repository at this point in the history
  • Loading branch information
minhkhul committed Jul 18, 2024
1 parent b1a628a commit 5946365
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/client/delphi_epidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Epidata:
debug = False # if True, prints extra logging statements
sandbox = False # if True, will not execute any queries

_version_checked=False

@staticmethod
def log(evt, **kwargs):
kwargs['event'] = evt
Expand All @@ -55,8 +57,10 @@ def log(evt, **kwargs):
# Check that this client's version matches the most recent available, runs just once per program execution (on initial module load).
@staticmethod
def _version_check():
_version_checked = True
try:
latest_version = requests.get('https://pypi.org/pypi/delphi-epidata/json').json()['info']['version']
request = requests.get('https://pypi.org/pypi/delphi-epidata/json', timeout=5)
latest_version = request.json()['info']['version']
if latest_version != __version__:
Epidata.log(
"Client version not up to date",
Expand Down Expand Up @@ -708,3 +712,6 @@ async def async_make_calls(param_combos):
future = asyncio.ensure_future(async_make_calls(param_list))
responses = loop.run_until_complete(future)
return responses

if Epidata._version_checked == False:
Epidata._version_check()

0 comments on commit 5946365

Please sign in to comment.