Skip to content

Commit 122a117

Browse files
authored
Asgi recv() on lambda should hang when there are no more events (#93)
This commit fixes a bug when running on AWS lambda. The asgi wrapper, before this commit, did not 'hang' when there are no more events to produce. With this commit when there are no more events we return a pending future.
1 parent c2cacb7 commit 122a117

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

python/restate/aws_lambda.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,19 @@ def request_to_receive(req: RestateLambdaRequest) -> Receive:
8787
"type": "http.request",
8888
"body": body,
8989
"more_body": False
90+
},
91+
{
92+
"type": "http.request",
93+
"body": b'',
94+
"more_body": False
9095
}])
9196

9297
async def recv() -> HTTPRequestEvent:
9398
if len(events) != 0:
94-
return events.pop()
95-
return {
96-
"type": "http.request",
97-
"body": b'',
98-
"more_body": False
99-
}
99+
return events.pop(0)
100+
# If we are out of events, return a future that will never complete
101+
f = asyncio.Future[HTTPRequestEvent]()
102+
return await f
100103

101104
return recv
102105

0 commit comments

Comments
 (0)