@@ -718,6 +718,53 @@ async def test_retire_workers(c, s, a, b):
718718 assert len (retired_workers_info ) == 2
719719
720720
721+ @gen_cluster (
722+ client = True ,
723+ clean_kwargs = {"threads" : False },
724+ config = {
725+ "distributed.scheduler.http.routes" : DEFAULT_ROUTES
726+ + ["distributed.http.scheduler.api" ]
727+ },
728+ )
729+ async def test_retire_workers_with_tuple_keys (c , s , a , b ):
730+ aiohttp = pytest .importorskip ("aiohttp" )
731+
732+ worker_address = "tcp://172.17.0.3:39571"
733+
734+ async def mock_retire_workers (* args , ** kwargs ):
735+ # Return problematic data structure
736+ # tuple are not json serializable
737+ return {
738+ worker_address : {
739+ "type" : "Worker" ,
740+ "metrics" : {
741+ "digests_total_since_heartbeat" : {
742+ (
743+ "execute" ,
744+ "slowadd" ,
745+ "thread-cpu" ,
746+ "seconds" ,
747+ ): 0.0003396660000000093 ,
748+ },
749+ },
750+ }
751+ }
752+
753+ # Replace the method with our mock
754+ s .retire_workers = mock_retire_workers
755+
756+ async with aiohttp .ClientSession () as session :
757+ params = {"workers" : [a .address , b .address ]}
758+ async with session .post (
759+ "http://localhost:%d/api/v1/retire_workers" % s .http_server .port ,
760+ json = params ,
761+ ) as resp :
762+ assert resp .status == 200
763+ assert resp .headers ["Content-Type" ] == "application/json"
764+ retired_workers_info = json .loads (await resp .text ())
765+ assert worker_address in retired_workers_info
766+
767+
721768@gen_cluster (
722769 client = True ,
723770 clean_kwargs = {"threads" : False },
0 commit comments