code: def test_cancellation(client):
      with client.get_executor(pure=False) as e:
          fut = e.submit(sleep, 2.0)
          start = time()
          while number_of_processing_tasks(client) == 0:
              assert time() < start + 30
              sleep(0.01)
          assert not fut.done()
  
          fut.cancel()
          assert fut.cancelled()
          start = time()
          while number_of_processing_tasks(client) != 0:
              assert time() < start + 30
              sleep(0.01)
  
          with pytest.raises(CancelledError):
              fut.result()
  
imports: from __future__ import annotations
  import random
  from concurrent.futures import FIRST_COMPLETED, FIRST_EXCEPTION, Future, TimeoutError, as_completed, wait
  from time import sleep
  import pytest
  from tlz import take
  from distributed.event import Event
  from distributed.metrics import time
  from distributed.utils import CancelledError
  from distributed.utils_test import inc, slowadd, slowinc, throws, varying
label_desc: Use image node_id 5 for calling a global function with example usage: test_cancellation(client) without return types