maroshmka commented on issue #12387:
URL: https://github.com/apache/airflow/issues/12387#issuecomment-731392455
I'm thinking if this is not more of a client issue. You're trying to read
files while one of those files is the one starting the reading. To me it sounds
that maximum recursion is the correct error over here, you're doing infinite
recursion and you should be aware of that, also you should control it in your
code.
I would achieve this by using some semaphore var to know if skip or not the
file:
```python
import os
loading = int(os.environ.get("AIRFLOW_DAGBAG_LOAD_GLOBAL_ACTIVE", "0"))
if loading == 0:
os.environ["AIRFLOW_DAGBAG_LOAD_GLOBAL_ACTIVE"] = "1"
dagbag = models.DagBag().dags
print(dagbag)
else:
print("skipping this file")
```
The var can be probably also inserted in `globals()`, haven't tested that
tho. The posted code should work.
Just be careful that it's in global scope (example uses env vars). Which
should be carefully used. In case you'd use it in multiple places you would
need to have more complex management if something should or shouldn't be read.
Hope it helps a bit.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]