@@ -78,10 +78,14 @@ def __init__(self, task_groups, max_workers_cnt, randomize):
78
78
self .worker_next_id = 1
79
79
80
80
tasks_cnt = 0
81
+ self .current_task_queue = SimpleQueue ()
81
82
self .task_queue_disps = dict ()
82
83
for key , task_group in task_groups .items ():
83
84
tasks_cnt += len (task_group ['task_ids' ])
84
- task_queue_disp = TaskQueueDispatcher (key , task_group , randomize )
85
+ task_queue_disp = TaskQueueDispatcher (key ,
86
+ task_group ,
87
+ randomize ,
88
+ self .current_task_queue )
85
89
self .task_queue_disps [key ] = task_queue_disp
86
90
self .result_queues .append (task_queue_disp .result_queue )
87
91
self .task_queues .append (task_queue_disp .task_queue )
@@ -97,6 +101,7 @@ def __init__(self, task_groups, max_workers_cnt, randomize):
97
101
98
102
self .pid_to_worker_id = dict ()
99
103
self .worker_id_to_pid = dict ()
104
+ self .worker_id_to_task = dict ()
100
105
101
106
self .randomize = randomize
102
107
self .tcp_port_dispatcher = TcpPortDispatcher ()
@@ -137,9 +142,19 @@ def init_listeners(self):
137
142
no_output_timeout = float (args .no_output_timeout or 120 )
138
143
hang_watcher = listeners .HangWatcher (
139
144
output_watcher .not_done_worker_ids , self .kill_all_workers ,
140
- warn_timeout , no_output_timeout )
145
+ warn_timeout , no_output_timeout ,
146
+ self .get_task_by_worker_id , self .set_task_for_worker_id
147
+ )
141
148
self .listeners .append (hang_watcher )
142
149
150
+ def set_task_for_worker_id (self ):
151
+ while not self .current_task_queue .empty ():
152
+ worker_id , task_id = self .current_task_queue .get ()
153
+ self .worker_id_to_task [worker_id ] = task_id
154
+
155
+ def get_task_by_worker_id (self , worker_id ):
156
+ return self .worker_id_to_task [worker_id ]
157
+
143
158
def run_max_workers (self ):
144
159
ok = True
145
160
new_workers_cnt = self .max_workers_cnt - self .workers_cnt
@@ -340,7 +355,7 @@ class TaskQueueDispatcher:
340
355
"""Incapsulate data structures necessary for dispatching workers working on
341
356
the one task queue.
342
357
"""
343
- def __init__ (self , key , task_group , randomize ):
358
+ def __init__ (self , key , task_group , randomize , current_task_queue ):
344
359
self .key = key
345
360
self .gen_worker = task_group ['gen_worker' ]
346
361
self .task_ids = task_group ['task_ids' ]
@@ -353,6 +368,7 @@ def __init__(self, key, task_group, randomize):
353
368
self .randomize = False
354
369
self .result_queue = SimpleQueue ()
355
370
self .task_queue = SimpleQueue ()
371
+ self .current_task_queue = current_task_queue
356
372
for task_id in self .task_ids :
357
373
self .task_queue .put (task_id )
358
374
self .worker_ids = set ()
@@ -366,7 +382,9 @@ def _run_worker(self, worker_id, tcp_port_range):
366
382
os .environ ['TEST_RUN_TCP_PORT_END' ] = str (tcp_port_range [1 ])
367
383
color_stdout .queue = self .result_queue
368
384
worker = self .gen_worker (worker_id )
369
- worker .run_all (self .task_queue , self .result_queue )
385
+ worker .run_all (self .task_queue ,
386
+ self .result_queue ,
387
+ self .current_task_queue )
370
388
371
389
def add_worker (self , worker_id , tcp_port_range ):
372
390
# Note: each of our workers should consume only one None, but for the
0 commit comments