@@ -674,20 +674,17 @@ class GraphConnectionHandler(AbstractAPI):
674
674
675
675
_version_info : dict = None
676
676
677
+ _lock : threading .RLock
678
+ """Reentrant mutex for thread safety"""
679
+
677
680
def __init__ (self ,
678
681
root_url : str = None ,
679
- raise_exceptions : bool = True ,
680
- proxies : dict = None ,
681
- headers : dict = None ,
682
- timeout : int = None ,
683
- client_name : str = None ,
684
682
custom_endpoints : dict = None ,
685
- ssl_config : SSLConfig = None ,
686
- log_communication_on_error : bool = None ,
687
- max_tries : int = None ,
688
683
pool_maxsize : int = None ,
689
684
pool_block : bool = None ,
690
- connection_handler = None ):
685
+ connection_handler = None ,
686
+ * args ,
687
+ ** kwargs ):
691
688
"""
692
689
Constructor
693
690
@@ -727,6 +724,8 @@ def __init__(self,
727
724
:param connection_handler: Copy parameters from this already existing connection handler. Overrides all other
728
725
parameters.
729
726
"""
727
+ self ._lock = threading .RLock ()
728
+
730
729
root_url = getattr (connection_handler , '_root_url' , root_url )
731
730
732
731
if not root_url :
@@ -743,15 +742,8 @@ def __init__(self,
743
742
super ().__init__ (
744
743
root_url = root_url ,
745
744
session = session ,
746
- raise_exceptions = raise_exceptions ,
747
- proxies = proxies ,
748
- timeout = timeout ,
749
- headers = headers ,
750
- client_name = client_name ,
751
- ssl_config = ssl_config ,
752
- log_communication_on_error = log_communication_on_error ,
753
- max_tries = max_tries ,
754
- abstract_api = connection_handler
745
+ abstract_api = connection_handler ,
746
+ ** kwargs
755
747
)
756
748
757
749
self .custom_endpoints = getattr (connection_handler , '_custom_endpoints' , custom_endpoints )
@@ -860,11 +852,12 @@ def get_version(self, force_update: bool = False) -> dict:
860
852
:param force_update: Force updating the internal cache with version_info via API request.
861
853
:return: The result payload
862
854
"""
863
- if not self ._version_info or force_update :
864
- url = self ._root_url + '/api/version'
865
- self ._version_info = self .get (url )
855
+ with self ._lock :
856
+ if not self ._version_info or force_update :
857
+ url = self ._root_url + '/api/version'
858
+ self ._version_info = self .get (url )
866
859
867
- return self ._version_info
860
+ return self ._version_info
868
861
869
862
870
863
###################################################################################################################
@@ -876,20 +869,7 @@ class AbstractTokenApiHandler(GraphConnectionHandler):
876
869
Root class for all TokenApiHandler classes. This adds token handling.
877
870
"""
878
871
879
- def __init__ (self ,
880
- root_url : str = None ,
881
- raise_exceptions : bool = True ,
882
- proxies : dict = None ,
883
- headers : dict = None ,
884
- timeout : int = None ,
885
- client_name : str = None ,
886
- custom_endpoints : dict = None ,
887
- ssl_config : SSLConfig = None ,
888
- log_communication_on_error : bool = None ,
889
- max_tries : int = None ,
890
- pool_maxsize : int = None ,
891
- pool_block : bool = None ,
892
- connection_handler : GraphConnectionHandler = None ):
872
+ def __init__ (self , * args , ** kwargs ):
893
873
"""
894
874
Constructor
895
875
@@ -933,21 +913,7 @@ def __init__(self,
933
913
unnecessary version information for each or building their own requests.Sessions. Overrides all other
934
914
parameters.
935
915
"""
936
- super ().__init__ (
937
- root_url = root_url ,
938
- raise_exceptions = raise_exceptions ,
939
- proxies = proxies ,
940
- headers = headers ,
941
- timeout = timeout ,
942
- client_name = client_name ,
943
- custom_endpoints = custom_endpoints ,
944
- ssl_config = ssl_config ,
945
- log_communication_on_error = log_communication_on_error ,
946
- max_tries = max_tries ,
947
- pool_maxsize = pool_maxsize ,
948
- pool_block = pool_block ,
949
- connection_handler = connection_handler
950
- )
916
+ super ().__init__ (* args , ** kwargs )
951
917
952
918
###############################################################################################################
953
919
# Token handling
@@ -1002,21 +968,7 @@ class FixedTokenApiHandler(AbstractTokenApiHandler):
1002
968
1003
969
_token : str
1004
970
1005
- def __init__ (self ,
1006
- root_url : str = None ,
1007
- token : str = None ,
1008
- raise_exceptions : bool = True ,
1009
- proxies : dict = None ,
1010
- headers : dict = None ,
1011
- timeout : int = 600 ,
1012
- client_name : str = None ,
1013
- custom_endpoints : dict = None ,
1014
- ssl_config : SSLConfig = None ,
1015
- log_communication_on_error : bool = None ,
1016
- max_tries : int = None ,
1017
- pool_maxsize : int = None ,
1018
- pool_block : bool = None ,
1019
- connection_handler : GraphConnectionHandler = None ):
971
+ def __init__ (self , token : str = None , * args , ** kwargs ):
1020
972
"""
1021
973
Constructor
1022
974
@@ -1046,21 +998,7 @@ def __init__(self,
1046
998
unnecessary version information for each or building their own requests.Sessions. Overrides all other
1047
999
parameters.
1048
1000
"""
1049
- super ().__init__ (
1050
- root_url = root_url ,
1051
- raise_exceptions = raise_exceptions ,
1052
- proxies = proxies ,
1053
- timeout = timeout ,
1054
- headers = headers ,
1055
- client_name = client_name ,
1056
- custom_endpoints = custom_endpoints ,
1057
- ssl_config = ssl_config ,
1058
- log_communication_on_error = log_communication_on_error ,
1059
- max_tries = max_tries ,
1060
- pool_maxsize = pool_maxsize ,
1061
- pool_block = pool_block ,
1062
- connection_handler = connection_handler
1063
- )
1001
+ super ().__init__ (* args , ** kwargs )
1064
1002
1065
1003
self ._token = token
1066
1004
@@ -1086,21 +1024,7 @@ class EnvironmentTokenApiHandler(AbstractTokenApiHandler):
1086
1024
1087
1025
_env_var : str
1088
1026
1089
- def __init__ (self ,
1090
- root_url : str = None ,
1091
- env_var : str = 'HIRO_TOKEN' ,
1092
- raise_exceptions : bool = True ,
1093
- proxies : dict = None ,
1094
- headers : dict = None ,
1095
- timeout : int = 600 ,
1096
- client_name : str = None ,
1097
- custom_endpoints : dict = None ,
1098
- ssl_config : SSLConfig = None ,
1099
- log_communication_on_error : bool = None ,
1100
- max_tries : int = None ,
1101
- pool_maxsize : int = None ,
1102
- pool_block : bool = None ,
1103
- connection_handler : GraphConnectionHandler = None ):
1027
+ def __init__ (self , env_var : str = 'HIRO_TOKEN' , * args , ** kwargs ):
1104
1028
"""
1105
1029
Constructor
1106
1030
@@ -1130,21 +1054,7 @@ def __init__(self,
1130
1054
unnecessary version information for each or building their own requests.Sessions. Overrides all other
1131
1055
parameters.
1132
1056
"""
1133
- super ().__init__ (
1134
- root_url = root_url ,
1135
- raise_exceptions = raise_exceptions ,
1136
- proxies = proxies ,
1137
- headers = headers ,
1138
- timeout = timeout ,
1139
- client_name = client_name ,
1140
- custom_endpoints = custom_endpoints ,
1141
- ssl_config = ssl_config ,
1142
- log_communication_on_error = log_communication_on_error ,
1143
- max_tries = max_tries ,
1144
- pool_maxsize = pool_maxsize ,
1145
- pool_block = pool_block ,
1146
- connection_handler = connection_handler
1147
- )
1057
+ super ().__init__ (* args , ** kwargs )
1148
1058
1149
1059
self ._env_var = env_var
1150
1060
@@ -1291,24 +1201,12 @@ class PasswordAuthTokenApiHandler(AbstractTokenApiHandler):
1291
1201
_secure_logging : bool = True
1292
1202
1293
1203
def __init__ (self ,
1294
- root_url : str = None ,
1295
1204
username : str = None ,
1296
1205
password : str = None ,
1297
1206
client_id : str = None ,
1298
1207
client_secret : str = None ,
1299
1208
secure_logging : bool = True ,
1300
- raise_exceptions : bool = True ,
1301
- proxies : dict = None ,
1302
- headers : dict = None ,
1303
- timeout : int = 600 ,
1304
- client_name : str = None ,
1305
- custom_endpoints : dict = None ,
1306
- ssl_config : SSLConfig = None ,
1307
- log_communication_on_error : bool = None ,
1308
- max_tries : int = None ,
1309
- pool_maxsize : int = None ,
1310
- pool_block : bool = None ,
1311
- connection_handler : GraphConnectionHandler = None ):
1209
+ * args , ** kwargs ):
1312
1210
"""
1313
1211
Constructor
1314
1212
@@ -1342,21 +1240,7 @@ def __init__(self,
1342
1240
unnecessary version information for each or building their own requests.Sessions. Overrides all other
1343
1241
parameters.
1344
1242
"""
1345
- super ().__init__ (
1346
- root_url = root_url ,
1347
- raise_exceptions = raise_exceptions ,
1348
- proxies = proxies ,
1349
- headers = headers ,
1350
- timeout = timeout ,
1351
- client_name = client_name ,
1352
- custom_endpoints = custom_endpoints ,
1353
- ssl_config = ssl_config ,
1354
- log_communication_on_error = log_communication_on_error ,
1355
- max_tries = max_tries ,
1356
- pool_maxsize = pool_maxsize ,
1357
- pool_block = pool_block ,
1358
- connection_handler = connection_handler
1359
- )
1243
+ super ().__init__ (* args , ** kwargs )
1360
1244
1361
1245
self ._username = username
1362
1246
self ._password = password
0 commit comments