File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -320,8 +320,11 @@ def ready(self, cluster):
320320 now = time .time ()
321321
322322 exhausted = bool (self ._free .queued () > 0 )
323- for tp , dq in six .iteritems (self ._batches ):
324-
323+ # several threads are accessing self._batches -- to simplify
324+ # concurrent access, we iterate over a snapshot of partitions
325+ # and lock each partition separately as needed
326+ partitions = list (self ._batches .keys ())
327+ for tp in partitions :
325328 leader = cluster .leader_for_partition (tp )
326329 if leader is None or leader == - 1 :
327330 unknown_leaders_exist = True
@@ -330,6 +333,7 @@ def ready(self, cluster):
330333 continue
331334
332335 with self ._tp_locks [tp ]:
336+ dq = self ._batches [tp ]
333337 if not dq :
334338 continue
335339 batch = dq [0 ]
You can’t perform that action at this time.
0 commit comments