code: def wait_on_watcher(preempt_context: core.PreemptContext) -> None:
      # It's racy as to when the watcher will actually see the signal.
      watcher = preempt_context._watcher
      assert watcher is not None
      for i in range(5):
          if watcher._should_preempt:
              break
          time.sleep((i / 10) ** 2)
      assert watcher._should_preempt is True, watcher._should_preempt
  
file_path: determined/harness/tests/core/test_preempt.py
imports: import threading
  import time
  from typing import Any, Dict, Tuple
  from unittest import mock
  import pytest
  from determined import core
  from tests import parallel
label_desc: Use image node_id 2 for calling a global function with example usage: wait_on_watcher(preempt_context) without return types