Srujan Jabbireddy
09/06/2024, 10:29 PMAUTHORIZATION_TOKEN = secret_block.get()
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'coroutine' object has no attribute 'get'
An exception occurred.
sys:1: RuntimeWarning: coroutine 'sync_compatible.<locals>.coroutine_wrapper.<locals>.ctx_call' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Marvin
09/06/2024, 10:29 PMAttributeError
and a RuntimeWarning
.
Before I continue with my unending enthusiasm, can you confirm that you are indeed using Prefect 3.x?Srujan Jabbireddy
09/06/2024, 10:30 PMSrujan Jabbireddy
09/06/2024, 10:30 PMMarvin
09/06/2024, 10:30 PMget
) on a coroutine that needs to be awaited. Welcome to async programming fun.
Here's what you need to do:
1. Await the Coroutine: Prefect 3.x seems to have introduced more async behavior, so you need to await those coroutines. Instead of secret_block.get()
, use await secret_block.get()
. This means your function needs to be async.
2. Sync Compatibility Hack: If restructuring your code to be async isn't palatable, you may consider using Prefect's sync-compatible decorator _sync_
. There’s a prefab workaround for this. Apparently, you can grab a blocking version of some async Prefect functions using _sync_(your_function).result
.
For more insightful reading on this, here are some links:
- Runtime context handling
- Blocks and secrets handling
Additionally, reviewing related GitHub issues:
- Issue with coroutine object attribute
- Type checker compatibility
- Coroutines not having attribute 'get'
If you decide to delve into this further or still face issues, these links should help steer you a bit more effectively through async-prefecture.
Feels better? No, of course, it doesn't. But you asked for it.