<@ULVA73B9P> With prefect 3.0 now having differenc...
# ask-marvin
c
@Marvin With prefect 3.0 now having differences with task.submit, how do i submit three tasks asynchronously without throwing an error? For example, taskA.submit() taskB.submit() taskC.submit() should submit at the same time. This worked in 2.0, but Im getting an error in 3.
m
It seems there's a known issue related to using
await
with
Task.submit()
in Prefect 3.0, causing a
TypeError
. The core problem is that
submit
returns a
PrefectConcurrentFuture
, which can't be directly awaited. ### Workaround Instead of awaiting the
submit
call, you can gather the tasks and await their results. Here's an example to submit multiple tasks asynchronously without errors:
Copy code
python
from prefect import flow, task
import asyncio

@task
async def task_a():
    print("Running Task A")
    
@task
async def task_b():
    print("Running Task B")
    
@task
async def task_c():
    print("Running Task C")

@flow
async def my_flow():
    task_a_future = task_a.submit()
    task_b_future = task_b.submit()
    task_c_future = task_c.submit()
    
    # Use asyncio.gather to run these concurrently
    await asyncio.gather(
        task_a_future.result(),
        task_b_future.result(),
        task_c_future.result()
    )

if __name__ == '__main__':
    asyncio.run(my_flow())
#### Relevant Link - GitHub Issue Always ensure that you are running the latest version of Prefect, as these issues might be fixed in the future. You can check the current version of Prefect by running:
Copy code
plaintext
pip install prefect --upgrade
d
@Marvin how can I export and import blocks into a different prefect instance
m
To export and import blocks between different Prefect instances, you can use the Prefect CLI commands. Here’s a step-by-step guide: ### Export Blocks 1. Use the
prefect block pull
command to pull blocks from the source Prefect instance and save them to a file. 2. Example command to export blocks:
Copy code
shell
   prefect block pull <block-type/block-name> --output blocks.json
Replace
<block-type/block-name>
with your specific block type and name. ### Import Blocks 1. Use the
prefect block push
command to push the exported blocks to the target Prefect instance. 2. Example command to import blocks:
Copy code
shell
   prefect block push blocks.json
### Steps to Execute: 1. Exporting from Source Instance:
Copy code
shell
   prefect block pull my-block/block-name --output blocks.json
2. Importing to Target Instance:
Copy code
shell
   prefect block push blocks.json
These commands allow you to transfer block configurations between different Prefect instances seamlessly. If you need more detailed information, you can find these commands in the Prefect documentation or GitHub issues. Unfortunately, the automated search didn't yield a direct page link, so I would recommend checking the Prefect CLI documentation for the most up-to-date details. Link to Prefect CLI Documentation