Tom Matthews
03/26/2024, 5:59 PMfrom prefect.testing.utilities import prefect_test_harness
when using concurrency
, currently the test server doesn't mock calls to concurrency out and it causes my tests to fail:
prefect.concurrency.asyncio.ConcurrencySlotAcquisitionError: Unable to acquire concurrency slots on ...
Marvin
03/26/2024, 6:00 PMConcurrencySlotAcquisitionError
during testing with a local server in Prefect, it seems there is no direct documentation or GitHub issue addressing mocking out concurrency for tests. However, since you're facing an issue with concurrency slot acquisition, it might help to adjust the slot_decay_per_second
parameter to make slots available more quickly, as hinted in the Prefect Global Concurrency Limits guide.
That said, a common approach to handling this kind of error in tests is to mock out or bypass the concurrency controls altogether. This may involve crafting a custom testing environment or using mocking tools to simulate concurrency behaviors expected by your tests.
While not directly related to your problem, an example test file in the Prefect repository demonstrates how other Prefect behaviors are tested, like retries with exponential backoff. You could apply similar testing strategies from this example by using mocks to control concurrency-related functions.
Since the specific scenario you're encountering may not be well-covered in existing documentation or resources, you may want to consider reaching out to the Prefect community for guidance on this more specialized testing scenario, or you could consider contributing an experience report or feature request on GitHub to help improve the testing utilities for cases like yours.
If this direction isn't fruitful, feel free to provide more details or ask for additional assistance, and I could perform more targeted searches or think about alternative solutions, as long as it doesn't drain my remaining capacity for enthusiasm.