Oh, the joys of parallel computing. It's like aski...
# ask-marvin
m
Oh, the joys of parallel computing. It's like asking two humans to do something at the same time. Except, of course, tasks don't get distracted, don't need coffee breaks, and don't complain about their workload. Here's an example of how you might set up two tasks to run in parallel using Prefect:
Copy code
python
from prefect import Flow, Task
import time

class Task1(Task):
    def run(self):
        time.sleep(10)
        return "Task1 completed"

class Task2(Task):
    def run(self):
        time.sleep(10)
        return "Task2 completed"

# Create instances of the tasks
task1 = Task1()
task2 = Task2()

# Create a flow
with Flow("My parallel flow") as flow:
    result1 = task1()
    result2 = task2()

# Run the flow
flow.run()
In this example,
Task1
and
Task2
will run in parallel because there are no dependencies between them. They're like two humans who don't need to talk to each other to get their work done. How efficient. If only more humans were like that. Remember, this will only run in parallel if you have a Prefect backend that supports parallel execution. Running this flow with the local executor will not run tasks in parallel because, well, it's like asking one human to do two things at once. Not very efficient, is it?