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

Commit d0cb4a1

Browse files
authored
Merge pull request #64 from dbluhm/fix/timeouts
fix: timeouts for send and await reply not applied to send
2 parents 46379b4 + a4f98a8 commit d0cb4a1

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

aries_staticagent/static_connection.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -655,14 +655,17 @@ async def send_and_await_returned_async(
655655
) -> Message:
656656
"""Send a message and wait for a message to be returned."""
657657

658-
with self.next(type_=type_, condition=condition) as next_message:
659-
await self.send_async(
660-
msg,
661-
return_route=return_route,
662-
plaintext=plaintext,
663-
anoncrypt=anoncrypt,
664-
)
665-
return await asyncio.wait_for(next_message, timeout)
658+
async def _time_boxed():
659+
with self.next(type_=type_, condition=condition) as next_message:
660+
await self.send_async(
661+
msg,
662+
return_route=return_route,
663+
plaintext=plaintext,
664+
anoncrypt=anoncrypt,
665+
)
666+
return await next_message
667+
668+
return await asyncio.wait_for(_time_boxed(), timeout)
666669

667670
async def await_message(
668671
self,

aries_staticagent/type.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from operator import is_not
44
from typing import Union
55
import re
6-
from semver import VersionInfo, parse
6+
from semver import VersionInfo
77

88
MTURI_RE = re.compile(r"(.*?)([a-z0-9._-]+)/(\d[^/]*)/([a-z0-9._-]+)$")
99

@@ -27,14 +27,14 @@ def from_str(cls, version_str):
2727
args.append("0")
2828
return Semver(*map(int, filter(partial(is_not, None), args)))
2929

30-
parts = parse(version_str)
30+
parts = VersionInfo.parse(version_str)
3131

3232
return cls(
33-
parts["major"],
34-
parts["minor"],
35-
parts["patch"],
36-
parts["prerelease"],
37-
parts["build"],
33+
parts.major,
34+
parts.minor,
35+
parts.patch,
36+
parts.prerelease,
37+
parts.build,
3838
)
3939

4040

examples/return_route_client.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ def main():
2121
endpoint='http://localhost:{}'.format(os.environ.get('PORT', 3000))
2222
)
2323
)
24-
reply = conn.send_and_await_reply({
25-
"@type": "https://didcomm.org/"
26-
"basicmessage/1.0/message",
27-
"~l10n": {"locale": "en"},
28-
"sent_time": utils.timestamp(),
29-
"content": "The Cron script has been executed."
30-
}, return_route='all')
24+
reply = conn.send_and_await_reply(
25+
{
26+
"@type": "https://didcomm.org/basicmessage/1.0/message",
27+
"~l10n": {"locale": "en"},
28+
"sent_time": utils.timestamp(),
29+
"content": "The Cron script has been executed."
30+
},
31+
return_route='all'
32+
)
3133
print('Msg from conn:', reply and reply.pretty_print())
3234

3335

0 commit comments

Comments
 (0)