Prasanth Kothuri

04/12/2022, 4:31 PM
Hello, I am receiving the following pickle error while registering my flow
File "/usr/local/lib/python3.8/dist-packages/cloudpickle/", line 73, in dumps
  File "/usr/local/lib/python3.8/dist-packages/cloudpickle/", line 602, in dump
    return Pickler.dump(self, obj)
TypeError: cannot pickle '_thread.lock' object
to make it simple it has just one task as below
def get_file_names():
    files = s3.Bucket(s3_bucket).objects.all()
    file_names = []
    for my_bucket_object in files:
        file_name = my_bucket_object.key
        regex =".ctl", str(file_name))

        if regex is not None:

    return file_names
and flow
# flow to chain the tasks
with Flow("my_flow", storage=storage, schedule=schedule) as f:
    ctl_files = get_file_names()
any ideas why prefect is unable to serialize / pickle ???

Anna Geller

04/12/2022, 4:34 PM
Yup, you likely use some not serializable object in your flow code 🙂 Perhaps you can switch to Script storage instead? this would make things easier.
Assuming you are using e.g. S3 storage with a local agent, here is how you could define this: