Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit d92243a

Browse files
committed
Fix error in send_and_await_reply_async
Signed-off-by: Daniel Bluhm <[email protected]>
1 parent c8d4b0b commit d92243a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

aries_staticagent/static_connection.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def pack(
217217
def next(
218218
self,
219219
type_: str = None,
220-
cond: Callable[[Message], bool] = None):
220+
condition: Callable[[Message], bool] = None):
221221
"""
222222
Context manager to claim the next message matching condtion, allowing
223223
temporary bypass of regular dispatch.
@@ -226,28 +226,28 @@ def next(
226226
to consume more than one or two, consider using a standard message
227227
handler or overriding the default dispatching mechanism.
228228
"""
229-
if cond and type_:
229+
if condition and type_:
230230
raise ValueError('Expected type or condtion, not both.')
231-
if cond and not callable(cond):
232-
raise TypeError('cond must be Callable[[Message], bool]')
231+
if condition and not callable(condition):
232+
raise TypeError('condition must be Callable[[Message], bool]')
233233

234-
if not cond and not type_:
234+
if not condition and not type_:
235235
# Collect everything
236236
def _default(_msg):
237237
return True
238-
cond = _default
238+
condition = _default
239239

240240
if type_:
241241
def _matches_type(msg):
242242
return msg.type == type_
243-
cond = _matches_type
243+
condition = _matches_type
244244

245245
next_message = asyncio.Future()
246-
self._next[cond] = next_message
246+
self._next[condition] = next_message
247247

248248
yield next_message
249249

250-
del self._next[cond]
250+
del self._next[condition]
251251

252252
async def handle(self, packed_message: bytes):
253253
"""Unpack and dispatch message to handler."""
@@ -317,14 +317,15 @@ async def send_and_await_reply_async(
317317
self,
318318
msg: Union[dict, Message],
319319
*,
320+
type_: str = None,
320321
condition: Callable[[Message], bool] = None,
321322
return_route: str = "all",
322323
plaintext: bool = False,
323324
anoncrypt: bool = False,
324325
timeout: int = None) -> Message:
325326
"""Send a message and wait for a reply."""
326327

327-
with self.next(condition) as next_message:
328+
with self.next(type_=type_, condition=condition) as next_message:
328329
await self.send_async(
329330
msg,
330331
return_route=return_route,
@@ -347,7 +348,7 @@ async def await_message(
347348
as a result of an action taken prior to calling await_message, use the
348349
`next` context manager instead.
349350
"""
350-
with self.next(type_, cond=condition) as next_message:
351+
with self.next(type_, condition=condition) as next_message:
351352
return await asyncio.wait_for(next_message, timeout)
352353

353354
def send(self, *args, **kwargs):

0 commit comments

Comments
 (0)