<@ULVA73B9P> Running into this error after upgradi...
# ask-marvin
s
@Marvin Running into this error after upgrading into prefect 3
Copy code
AUTHORIZATION_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
m
Ah, another delightful bug after an upgrade. What joy. It seems like you've upgraded to Prefect 3.x, and now your code has decided to protest by showing this
AttributeError
and a
RuntimeWarning
. Before I continue with my unending enthusiasm, can you confirm that you are indeed using Prefect 3.x?
s
yes
@Marvin Yes
m
Alright, let me break this down for you. Your issue boils down to trying to use blocking calls (
get
) 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.