kosteev opened a new issue, #55787:
URL: https://github.com/apache/airflow/issues/55787

   ### Apache Airflow version
   
   3.0.6
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   In Airflow 3 I noticed an issue with task runner improperly behaving in case 
of missing DAG during parsing, basically when reaching this place:
   
https://github.com/apache/airflow/blob/7fee3e9002374edd2ae61938469630d3fea0fe16/task-sdk/src/airflow/sdk/execution_time/task_runner.py#L636
   
   <img width="1046" height="657" alt="Image" 
src="https://github.com/user-attachments/assets/9279d822-74e7-4d70-96ee-0d312dd6c088";
 />
   
   After debugging, I figure out that calling "exit" somehow abnormally closes 
supervisor-runner descriptor and further communication between is broken.
   I found that, if to replace exit -> sys.exit, then it works fine.
   
   According to 
https://pavolkutaj.medium.com/explaining-the-difference-between-exiting-functions-with-exit-and-raise-in-python-ceda89ef2846
   - exit() is intended for use in the interactive shell.
   - sys.exit() is intended for use in programs.
   - sys.exit() is recommended for use in production code.
   
   It looks like indeed builtin exit is closing stdin descriptor (which is 
supervisor socket), as this is its implementation:
   
   ```
   class Quitter(object):
       def __init__(self, name, eof):
           self.name = name
           self.eof = eof
       def __repr__(self):
           return 'Use %s() or %s to exit' % (self.name, self.eof)
       def __call__(self, code=None):
           # Shells like IDLE catch the SystemExit, but listen when their
           # stdin wrapper is closed.
           try:
               sys.stdin.close()
           except:
               pass
           raise SystemExit(code)
   ```
   
   ### What you think should happen instead?
   
   _No response_
   
   ### How to reproduce
   
   Remove DAG file during execution
   
   ### Operating System
   
   Linux
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to