Could you tell me how to invoke the class that is ...
# prefect-ui
a
Could you tell me how to invoke the class that is called between tasks ?
k
Hey @Anh Nguyen, not sure what you are asking. Are you saying there is a class that you need in tasks? Similar to this?
Copy code
cls = MyClass()

@task
def task_A():
    cls.do_something()
    return
a
Thanks Bro! I has a questions: How to make a connection which is used in many task? Plz, Give me the example for that
k
This is harder because connections send to be unserializeable and Dask uses
cloudpickle
to send stuff to the workers. So the limitations here are that you need to use LocalExecutor or LocalDaskExecutor (with threads) and then:
Copy code
cls = MyClass()

@task
def task_A():
    cls.do_something()
    return

with Flow(...) as flow:
     task_A.map([1,2,3])
but this requires your flow to be stored as a script because the default behavior is to serialize your Flow and these connections cant be serialized