I am currently creating an engine in my DAG and passing this sqlalchemy engine as a parameter to PythonOperator to execute some database work. e.g.
PythonOperator(python_callable=my_callable,
op_args=[engine],
provide_context=True,
task_id = 'my_task',
dag=dag)
When I try to clear the status of tasks, I get an error
File "/opt/conda/lib/python3.7/copy.py", line 169, in deepcopy
rv = reductor(4)
TypeError: can't pickle _thread._local objects
This is most likely because you can't pickle engine objects:
pickle.dumps(engine)
TypeError: can't pickle _thread._local objects
I'm wondering if there's a good way to get around this so I can use the Airflow webserver effectively. I need to pass the python callable something that would allow it to interact with the database, and it could be the connection string, but it is easier to make the engine once in the DAG and pass it to all of the Operators than make the engine in each one.