Skip to content

Commit 0c7f870

Browse files
committed
Fix: PineconeGrpcFuture blocks during construction
When using grpc with async_req, the construction of a PineconeGrpcFuture would call _sync_state, which would do a blocking call to grpc_future.exception(...). This means that the async_reqs were all blocking in practice. We can fix it by checking if the future is still running and not doing any blocking calls when it is.
1 parent e22773f commit 0c7f870

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pinecone/grpc/future.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,16 @@ def _sync_state(self, grpc_future):
3030
if self.done():
3131
return
3232

33-
if grpc_future.cancelled():
33+
if grpc_future.running():
34+
self.set_running_or_notify_cancel()
35+
elif grpc_future.cancelled():
3436
self.cancel()
35-
elif grpc_future.exception(timeout=self._default_timeout):
36-
self.set_exception(grpc_future.exception())
3737
elif grpc_future.done():
3838
try:
3939
result = grpc_future.result(timeout=self._default_timeout)
4040
self.set_result(result)
4141
except Exception as e:
4242
self.set_exception(e)
43-
elif grpc_future.running():
44-
self.set_running_or_notify_cancel()
4543

4644
def set_result(self, result):
4745
if self._result_transformer:

0 commit comments

Comments
 (0)