@@ -46,33 +46,38 @@ class Epidata:
4646 debug = False # if True, prints extra logging statements
4747 sandbox = False # if True, will not execute any queries
4848
49- _version_checked = False
49+ _version_checked = False
5050
5151 @staticmethod
5252 def log (evt , ** kwargs ):
5353 kwargs ['event' ] = evt
5454 kwargs ['timestamp' ] = time .strftime ("%Y-%m-%d %H:%M:%S %z" )
5555 return sys .stderr .write (str (kwargs ) + "\n " )
5656
57- # Check that this client's version matches the most recent available, runs just once per program execution (on initial module load).
57+ # Check that this client's version matches the most recent available.
58+ # This is indended to run just once per program execution, on initial module load.
59+ # See the bottom of this file for the ultimate call to this method.
5860 @staticmethod
5961 def _version_check ():
60- _version_checked = True
62+ if Epidata ._version_checked :
63+ # already done; nothing to do!
64+ return
65+
66+ Epidata ._version_checked = True
67+
6168 try :
6269 request = requests .get ('https://pypi.org/pypi/delphi-epidata/json' , timeout = 5 )
6370 latest_version = request .json ()['info' ]['version' ]
64- if latest_version != __version__ :
65- Epidata .log (
66- "Client version not up to date" ,
67- client_version = __version__ ,
68- latest_version = latest_version
69- )
7071 except Exception as e :
7172 Epidata .log ("Error getting latest client version" , exception = str (e ))
73+ return
7274
73- # Run this once on module load. Use dunder method for Python <= 3.9 compatibility
74- # https://stackoverflow.com/a/12718272
75- _version_check .__func__ ()
75+ if latest_version != __version__ :
76+ Epidata .log (
77+ "Client version not up to date" ,
78+ client_version = __version__ ,
79+ latest_version = latest_version
80+ )
7681
7782 # Helper function to cast values and/or ranges to strings
7883 @staticmethod
@@ -713,5 +718,6 @@ async def async_make_calls(param_combos):
713718 responses = loop .run_until_complete (future )
714719 return responses
715720
716- if Epidata ._version_checked == False :
717- Epidata ._version_check ()
721+
722+
723+ Epidata ._version_check ()
0 commit comments