Kayvan Shah
05/26/2022, 7:36 AMTraceback (most recent call last):
File "/home/kayvan/anaconda3/envs/prefect-conda/lib/python3.9/site-packages/prefect/engine.py", line 468, in orchestrate_flow_run
result = await run_sync_in_worker_thread(flow_call)
File "/home/kayvan/anaconda3/envs/prefect-conda/lib/python3.9/site-packages/prefect/utilities/asyncio.py", line 54, in run_sync_in_worker_thread
return await anyio.to_thread.run_sync(call, cancellable=True)
File "/home/kayvan/anaconda3/envs/prefect-conda/lib/python3.9/site-packages/anyio/to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/home/kayvan/anaconda3/envs/prefect-conda/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "/home/kayvan/anaconda3/envs/prefect-conda/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "/home/kayvan/projects/prefect-demo/flows/spire_current_weather.py", line 55, in spire_current_weather
sample = random.choice(conf)
File "/home/kayvan/anaconda3/envs/prefect-conda/lib/python3.9/random.py", line 346, in choice
return seq[self._randbelow(len(seq))]
TypeError: object of type 'PrefectFuture' has no len()
using random.choice() to select randomly from a listKevin Kho
.result()
and then you can use the random.choice()
Kayvan Shah
05/26/2022, 3:49 PM