Skip to content

Unable to use Prefect with stateful flows #15806

Discussion options

You must be logged in to vote

hmm, I'm not sure I understand your intended use of threading.Lock in this context

if the above represents what you're trying to do, what about this? i.e just call your dask work (instance method or not) from a flow

docs on this

# /// script
# dependencies = [
#     "numpy",
#     "prefect-dask",
# ]
# ///

import numpy as np
from prefect_dask import DaskTaskRunner
from prefect import flow, task

@task(task_run_name="dask work on input: {arg}")
def work(arg):
    print(f"Starting task in a function with argument: {arg}")
    return arg

@flow(task_runner=DaskTaskRunner())
def submit_to_dask(n: int = 100):
    return [work.submit(1) for i in range(n)]

class MainObj:
    def __init__(self, x

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@RaphaelRobidas
Comment options

Comment options

You must be logged in to vote
5 replies
@zzstoatzz
Comment options

Answer selected by RaphaelRobidas
@RaphaelRobidas
Comment options

@zzstoatzz
Comment options

@RaphaelRobidas
Comment options

@zzstoatzz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants