Skip to content

Commit

Permalink
Merge pull request #573 from CodeCorrupt/master
Browse files Browse the repository at this point in the history
Fix bug with RPC when handling on_close with a RobustConnection
  • Loading branch information
mosquito authored Aug 14, 2023
2 parents c8e33c5 + e951c72 commit e993211
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions aio_pika/patterns/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,20 @@ def __init__(
self.consumer_tags: Dict[Callable[..., Any], ConsumerTag] = {}
self.host_exceptions = host_exceptions

def __remove_future(self, future: asyncio.Future) -> None:
log.debug("Remove done future %r", future)
self.futures.pop(str(id(future)), None)
def __remove_future(
self, correlation_id: str
) -> Callable[[asyncio.Future], None]:
def do_remove(future: asyncio.Future) -> None:
log.debug("Remove done future %r", future)
self.futures.pop(correlation_id, None)
return do_remove

def create_future(self) -> Tuple[asyncio.Future, str]:
future = self.loop.create_future()
log.debug("Create future for RPC call")
correlation_id = str(uuid.uuid4())
self.futures[correlation_id] = future
future.add_done_callback(self.__remove_future)
future.add_done_callback(self.__remove_future(correlation_id))
return future, correlation_id

async def close(self) -> None:
Expand Down

0 comments on commit e993211

Please sign in to comment.