Taragolis commented on code in PR #38893:
URL: https://github.com/apache/airflow/pull/38893#discussion_r1559406439


##########
tests/jobs/test_local_task_job.py:
##########
@@ -886,53 +907,53 @@ def test_process_sigterm_works_with_retries(
         execution_date = DEFAULT_DATE
         run_id = f"test-{execution_date.date().isoformat()}"
 
-        # Run LocalTaskJob in separate process
-        proc = mp_context.Process(
-            target=self._sigterm_local_task_runner,
-            args=(dag_id, task_id, run_id, execution_date, task_started, 
retry_callback_called),
-            name="LocalTaskJob-TestProcess",
-            daemon=daemon,
-        )
-        proc.start()
-
-        try:
-            with timeout(wait_timeout, "Timeout during waiting start 
LocalTaskJob"):
-                while task_started.value == 0:
-                    time.sleep(0.2)
-            os.kill(proc.pid, signal.SIGTERM)
-
-            with timeout(wait_timeout, "Timeout during waiting callback"):
-                while retry_callback_called.value == 0:
-                    time.sleep(0.2)
-        finally:
-            proc.kill()
-
-        assert retry_callback_called.value == 1
-        # Internally callback finished before TaskInstance commit changes in 
DB (as of Jan 2022).
-        # So we can't easily check TaskInstance.state without any race 
conditions drawbacks,
-        # and fact that process with LocalTaskJob could be already killed.
-        # We could add state validation (`UP_FOR_RETRY`) if callback mechanism 
changed.
-
-        pytest_capture = request.config.option.capture
-        if pytest_capture == "no":
-            # Since we run `LocalTaskJob` in the separate process we can grab 
ut easily by `caplog`.
-            # However, we could grab it from stdout/stderr but only if `-s` 
flag set, see:
-            # https://github.com/pytest-dev/pytest/issues/5997
-            captured = capfd.readouterr()
+        with tempfile.NamedTemporaryFile() as tmpfile:

Review Comment:
   [`How to use temporary directories and files in tests: The tmp_path 
fixture`](https://docs.pytest.org/en/stable/how-to/tmp_path.html)



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