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

   ### Apache Airflow version
   
   2.9.3
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   When attempting to run the simple tutorial from:
   
   
https://airflow.apache.org/docs/apache-airflow/stable/tutorial/fundamentals.html
   
   on a Windows machine,  there are two minor issues preventing this from 
working on Windows (related to  https://github.com/apache/airflow/issues/10388).
   
   I resolved these issues locally and it seems to work on Windows now, but as 
I am extremely new to Airflow and know nothing of the code base, I am not sure 
of any ramifications for Linux, but sharing for someone more familiar with the 
code base to confirm:
   
   in airflow/hooks/subprocess.py line 77 in run_command() method:
   
   ```
               self.sub_process = Popen(
                   command,
                   stdout=PIPE,
                   stderr=STDOUT,
                   cwd=cwd,
                   env=env if env or env == {} else os.environ,
                   preexec_fn=pre_exec,
               )
   ```
   
   fix #1: if running under Windows, set `preexec_fn=None`.
   
   fix #2: for Popen call, we also need to pass in `close_fds=True`. On 
Windows, the code as is, will result in a race condition where the sub_process 
has not fully released the directory created in `cwd = 
stack.enter_context(TemporaryDirectory(prefix="airflowtmp"))`, and we'll get an 
exception:
   
   ```
     File "C:\Program 
Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\shutil.py",
 line 637, in _rmtree_unsafe
       os.rmdir(path)
   PermissionError: [WinError 32] The process cannot access the file because it 
is being used by another process: 
'C:\\Users\\xxx\\AppData\\Local\\Temp\\airflowtmpngs54_vn'
   ```
   
   
   ### What you think should happen instead?
   
   _No response_
   
   ### How to reproduce
   
   Running the simple tutorial at 
https://airflow.apache.org/docs/apache-airflow/stable/tutorial/fundamentals.html
 on a Windows box in Pycharm a few times will result in the exception.
   
   ### Operating System
   
   Windows 11
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   Race condition exception occurs 95% of the time when attempting to run the 
tutorial.
   
   ### Are you willing to submit PR?
   
   - [ ] 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