Replies: 2 comments 1 reply
-
Hi @hughgrigg! We currently do not use I will keep this discussion open to update as soon as we have answers and I am tagging @heitorlessa who has more experience in these async tests and the batch utility. Thanks |
Beta Was this translation helpful? Give feedback.
-
Apologies, after some more investigation, it turned out that this was due to how TLDR this is not a problem with |
Beta Was this translation helpful? Give feedback.
-
My project uses Lambda Powertools
AsyncBatchProcessor
, andpytest-asyncio
for tests.This causes problems during test runs, as
AsyncBatchProcessor
calls eitherloop.run_until_complete
orasyncio.run
, depending on theLAMBDA_TASK_ROOT_ENV
env var. https://github.com/aws-powertools/powertools-lambda-python/blob/develop/aws_lambda_powertools/utilities/batch/base.py#L126This clashes with the event loop that
pytest-asyncio
is using to run the async tests. When a test callslambda_handler
, it leads to one of these two errors due to the above:I can workaround this in a single test case by running
lambda_handler
in a thread pool executor from the test like this:But when running multiple test cases in the same test process, the first cases passes, but all subsequent test cases hit this error:
Has anyone else been able to get
pytest-asyncio
to work withAsyncBatchProcessor
?Beta Was this translation helpful? Give feedback.
All reactions