Skip to content

Commit

Permalink
Fix async bug (#606)
Browse files Browse the repository at this point in the history
Signed-off-by: dragondriver <[email protected]>
  • Loading branch information
longjiquan authored Jul 12, 2021
1 parent 8486e8a commit 8b5fd24
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions pymilvus/client/asynch.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ def result(self, **kwargs):
with self._condition:
# future not finished. wait callback being called.
to = kwargs.get("timeout", None)
# when result() was called more than once, future.done() return True
if self._future and not self._future.done():
if self._future and self._results is None:
self._response = self._future.result(timeout=to)
self._results = self.on_response(self._response)

Expand Down Expand Up @@ -131,7 +130,7 @@ def is_done(self):
def done(self):
# self.exception()
with self._condition:
if self._future and not self._future.done():
if self._future and self._results is None:
try:
self._response = self._future.result()
self._results = self.on_response(self._response)
Expand Down Expand Up @@ -176,15 +175,16 @@ def result(self, **kwargs):
self.exception()
with self._condition:
to = kwargs.get("timeout", None)
for future in self._future_list:
# when result() was called more than once, future.done() return True
if future and not future.done():
self._response.append(future.result(timeout=to))
if self._results is None:
for future in self._future_list:
# when result() was called more than once, future.done() return True
if future and not future.done():
self._response.append(future.result(timeout=to))

if len(self._response) > 0 and not self._results:
self._results = self.on_response(self._response)
if len(self._response) > 0 and not self._results:
self._results = self.on_response(self._response)

self._callback()
self._callback()

self._done = True

Expand Down Expand Up @@ -213,17 +213,18 @@ def is_done(self):
def done(self):
# self.exception()
with self._condition:
try:
for future in self._future_list:
if future and not future.done():
self._response.append(future.result(timeout=None))
if self._results is None:
try:
for future in self._future_list:
if future and not future.done():
self._response.append(future.result(timeout=None))

if len(self._response) > 0 and not self._results:
self._results = self.on_response(self._response)
self._callback() # https://github.com/milvus-io/milvus/issues/6160
if len(self._response) > 0 and not self._results:
self._results = self.on_response(self._response)
self._callback() # https://github.com/milvus-io/milvus/issues/6160

except Exception as e:
self._exception = e
except Exception as e:
self._exception = e

self._condition.notify_all()

Expand Down

0 comments on commit 8b5fd24

Please sign in to comment.