OliverWannenwetsch commented on code in PR #43153:
URL: https://github.com/apache/airflow/pull/43153#discussion_r1810293495


##########
providers/src/airflow/providers/edge/cli/edge_command.py:
##########
@@ -94,6 +94,33 @@ def _hostname() -> str:
 def _pid_file_path(pid_file: str | None) -> str:
     return cli_utils.setup_locations(process=EDGE_WORKER_PROCESS_NAME, 
pid=pid_file)[0]
 
+def _write_pid_to_pidfile(pid_file_path):
+    """
+    Write PIDs for Edge Workers to disk,
+    ensuring that orphanded PID files from crashed instance are handled.
+    """
+    if pid_file_path.exists():
+        # Handle existing PID files on disk
+        logger.info("An existing PID file has been found: %s.", pid_file_path)
+        pid_stored_in_pid_file = read_pid_from_pidfile(pid_file_path)
+        if os.getpid() == pid_stored_in_pid_file:

Review Comment:
   Using `i_am_locking()` would require to use a the class `PIDLockFile`, this 
would require that we port the complete provider to use a Lockfile instead of a 
simple PID file. 



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