Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ def __init__(self, parent, *args, **kwargs):

self.client_class = self.generate_client_class()

# Prefer the Locust user's HTTP client so every simulated user maintains its own
# socket pool. Fall back to the shared class attribute for backwards compatibility.
locust_http_client = getattr(getattr(self, "user", None), "client", None)
if locust_http_client is None:
locust_http_client = EdFiAPIClient.client

self._api_client: EdFiAPIClient = self.client_class(
client=EdFiAPIClient.client, token=EdFiAPIClient.token
client=locust_http_client, token=EdFiAPIClient.token
)

def __getattr__(self, item):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ class VolumeTestUser(FastHttpUser):
volume_test_root_namespace: str = "edfi_performance_test.tasks.volume."

def on_start(self):
# Always associate the current user's HTTP client with the EdFiAPIClient so that
# every simulated Locust user maintains its own socket/connection pool.
EdFiAPIClient.client = self.client

if VolumeTestUser.is_initialized:
return

EdFiAPIClient.client = self.client
EdFiAPIClient.token = None

# Import root pipeclean modules
Expand Down
Loading