code: def test_lock_sync(client):
      def f(x):
          with Lock("x") as lock:
              client = get_client()
              assert client.get_metadata("locked") is False
              client.set_metadata("locked", True)
              sleep(0.05)
              assert client.get_metadata("locked") is True
              client.set_metadata("locked", False)
  
      client.set_metadata("locked", False)
      futures = client.map(f, range(10))
      client.gather(futures)
  
file_path: distributed/distributed/tests/test_locks.py
imports: from __future__ import annotations
  import pickle
  from datetime import timedelta
  from time import sleep
  import pytest
  from distributed import Lock, get_client
  from distributed.metrics import time
  from distributed.utils_test import gen_cluster
label_desc: Use image node_id 2 for calling a global function with example usage: test_lock_sync(client) without return types