[ 
https://issues.apache.org/jira/browse/AIRFLOW-5615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17112043#comment-17112043
 ] 

ASF GitHub Bot commented on AIRFLOW-5615:
-----------------------------------------

kaxil commented on a change in pull request #6311:
URL: https://github.com/apache/airflow/pull/6311#discussion_r427913444



##########
File path: tests/conftest.py
##########
@@ -415,3 +417,39 @@ def pytest_runtest_setup(item):
         skip_quarantined_test(item)
     skip_if_credential_file_missing(item)
     skip_if_airflow_2_test(item)
+
+
+@pytest.fixture
+def frozen_sleep(monkeypatch):
+    """
+    Use freezegun to "stub" sleep, so that it takes no time, but that
+    ``datetime.now()`` appears to move forwards
+
+    If your module under test does ``import time`` and then ``time.sleep``::
+
+        def test_something(frozen_sleep):
+            my_mod.fn_under_test()
+
+
+    If your module under test does ``from time import sleep`` then you will
+    have to mock that sleep function directly::
+
+        def test_something(frozen_sleep, monkeypatch):
+            monkeypatch.setattr('my_mod.sleep', frozen_sleep)
+            my_mod.fn_under_test()
+    """
+    freezegun_control = None
+
+    def fake_sleep(seconds):
+        nonlocal freezegun_control

Review comment:
       `nonlocal` isn't available for Py2 so if we plan to backport it, we will 
have to change it




----------------------------------------------------------------
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:
us...@infra.apache.org


> BaseJob subclasses shouldn't implement own heartbeat logic
> ----------------------------------------------------------
>
>                 Key: AIRFLOW-5615
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-5615
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.10.5
>            Reporter: Ash Berlin-Taylor
>            Assignee: Ash Berlin-Taylor
>            Priority: Trivial
>             Fix For: 2.0.0
>
>
> Both SchedulerJob and LocalTaskJob have their own timers and decide when to 
> call heartbeat based upon that.
> That logic should be removed and live in BaseJob to simplify the code.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to