code: def test_constrained_tasks_respect_priority(ws):
      ws.available_resources = {"R": 1}
      ws.total_resources = {"R": 1}
      RR = {"resource_restrictions": {"R": 1}}
  
      instructions = ws.handle_stimulus(
          ComputeTaskEvent.dummy(key="clog", **RR, stimulus_id="clog"),
          ComputeTaskEvent.dummy(
              key="x1", priority=(1,), **RR, stimulus_id="s1"
          ),
          ComputeTaskEvent.dummy(
              key="x2", priority=(2,), **RR, stimulus_id="s2"
          ),
          ComputeTaskEvent.dummy(
              key="x3", priority=(0,), **RR, stimulus_id="s3"
          ),
          ExecuteSuccessEvent.dummy(
              key="clog", stimulus_id="s4"
          ),  # start x3
          ExecuteSuccessEvent.dummy(
              key="x3", stimulus_id="s5"
          ),  # start x1
          ExecuteSuccessEvent.dummy(
              key="x1", stimulus_id="s6"
          ),  # start x2
      )
      assert instructions == [
          Execute(key="clog", stimulus_id="clog"),
          TaskFinishedMsg.match(key="clog", stimulus_id="s4"),
          Execute(key="x3", stimulus_id="s4"),
          TaskFinishedMsg.match(key="x3", stimulus_id="s5"),
          Execute(key="x1", stimulus_id="s5"),
          TaskFinishedMsg.match(key="x1", stimulus_id="s6"),
          Execute(key="x2", stimulus_id="s6"),
      ]
  
file_path: distributed/distributed/tests/test_resources.py
imports: from __future__ import annotations
  import asyncio
  import pytest
  import dask
  from dask import delayed
  from distributed import Lock, Worker
  from distributed.client import wait
  from distributed.utils_test import NO_AMM, gen_cluster, inc, lock_inc, slowadd, slowinc
  from distributed.worker_state_machine import ComputeTaskEvent, Execute, ExecuteFailureEvent, ExecuteSuccessEvent, FreeKeysEvent, LongRunningMsg, RescheduleEvent, TaskFinishedMsg
label_desc: Use image node_id 3 for calling a global function with example usage: test_constrained_tasks_respect_priority(ws) without return types