[Python-Dev] Re: Decreasing refcount for locals before popping frame

2022年4月28日 23:51:41 -0700

On 2022年4月29日 at 06:38, Thomas Grainger <[email protected]> wrote:
> Can you show a run-able example of the successful and unsuccessful usage of 
> `with DAG(): ... `?
from airflow import DAG
# correct:
dag = DAG("my_dag")
# incorrect:
DAG("my_dag")
The with construct really has nothing to do with it, but it is a
common source of confusion:
# incorrect
with DAG("my_dag"):
 ...
It is less obvious (to some) in this way that the entire DAG will not
be picked up. You will in fact have to write:
# correct
with DAG("my_dag") as dag:
 ...
This way, you're capturing the DAG in the top-level scope which is the
requirement.
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/HREOTTGPB5JMLGYMIQL4VR2DFI6GBG5J/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to