Skip to content

Commit

Permalink
Merge pull request #1938 from minrk/cancel-future
Browse files Browse the repository at this point in the history
avoid warning in race when cancelled future ignores zmq.Again
  • Loading branch information
minrk authored Feb 19, 2024
2 parents b24cda9 + 2febf54 commit b8db5e2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions zmq/_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,16 @@ def _deserialize(self, recvd, load):
def _chain(_):
"""Chain result through serialization to recvd"""
if f.done():
# chained future may be cancelled, which means nobody is going to get this result
# if it's an error, that's no big deal (probably zmq.Again),
# but if it's a successful recv, this is a dropped message!
if not recvd.cancelled() and recvd.exception() is None:
warnings.warn(
# is there a useful stacklevel?
# ideally, it would point to where `f.cancel()` was called
f"Future {f} completed while awaiting {recvd}. A message has been dropped!",
RuntimeWarning,
)
return
if recvd.exception():
f.set_exception(recvd.exception())
Expand Down

0 comments on commit b8db5e2

Please sign in to comment.