File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ def get_jwks():
1313 if key not in settings .JWKS_CACHE :
1414 missing = True
1515 if not missing :
16- print ("Can used cached keys" )
1716 return settings .JWKS_CACHE
1817 # Make a request to get the JWKS
1918 for key in settings .JWKS_URL :
Original file line number Diff line number Diff line change 1717THREADS = 16
1818
1919
20- def make_request ():
21- access_token , _ = get_tokens ()
22-
23- url = "http://localhost:80/analytics/"
20+ def make_request (token : str ):
21+ url = "http://localhost:8000/analytics/"
2422 payload = json .dumps (
2523 {
2624 "product" : random .randint (1 , 10 ),
@@ -42,7 +40,7 @@ def make_request():
4240 )
4341 headers = {
4442 "Content-Type" : "application/json" ,
45- "Authorization" : f"Bearer { access_token } " ,
43+ "Authorization" : f"Bearer { token } " ,
4644 }
4745
4846 try :
@@ -56,8 +54,10 @@ def make_request():
5654
5755def run_threads ():
5856 with ThreadPoolExecutor (max_workers = THREADS ) as executor :
57+ # Fetch token once to improve performance
58+ access_token , _ = get_tokens ()
5959 for _ in range (NUMBER_OF_REQUESTS ):
60- executor .submit (make_request )
60+ executor .submit (make_request , access_token )
6161
6262
6363def test_load ():
You can’t perform that action at this time.
0 commit comments