chanzuckerberg / cryoet-data-portal

CryoET Data Portal
MIT License
19 stars 10 forks source link

Update the API client to support multithreaded applications #1330

Open jgadling opened 2 weeks ago

jgadling commented 2 weeks ago

Right now the API client creates one HTTP transport and one GQL client object for the lifetime of the client object:

https://github.com/chanzuckerberg/cryoet-data-portal/blob/main/client/python/cryoet_data_portal/src/cryoet_data_portal/_client.py#L32-L46

This works fine in single threaded applications, but when the client is embedded in multi-threaded applications, race conditions are invoked against the http transport object, and this causes user applications to fail.

I don't think the libraries we're have any native threading support, but it's worth a few minutes of googling.

Most likely the expectation for this ticket is to update the client to dynamically create a new graphql client and http transport for every request to avoid this problem.