Skip to content

Commit ee0b09c

Browse files
committed
loadscope: use dict instead of OrderedDict
These days dicts are guaranteed to be ordered, so no need to use OrderedDict in two of the three cases (the remaining case needs `popitem(last=False)`).
1 parent 024c73f commit ee0b09c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/xdist/scheduler/loadscope.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def __init__(self, config, log=None):
9090
self.collection = None
9191

9292
self.workqueue = OrderedDict()
93-
self.assigned_work = OrderedDict()
94-
self.registered_collections = OrderedDict()
93+
self.assigned_work = {}
94+
self.registered_collections = {}
9595

9696
if log is None:
9797
self.log = Producer("loadscopesched")
@@ -156,7 +156,7 @@ def add_node(self, node):
156156
bootstraps a new node.
157157
"""
158158
assert node not in self.assigned_work
159-
self.assigned_work[node] = OrderedDict()
159+
self.assigned_work[node] = {}
160160

161161
def remove_node(self, node):
162162
"""Remove a node from the scheduler.
@@ -252,7 +252,7 @@ def _assign_work_unit(self, node):
252252
scope, work_unit = self.workqueue.popitem(last=False)
253253

254254
# Keep track of the assigned work
255-
assigned_to_node = self.assigned_work.setdefault(node, default=OrderedDict())
255+
assigned_to_node = self.assigned_work.setdefault(node, {})
256256
assigned_to_node[scope] = work_unit
257257

258258
# Ask the node to execute the workload
@@ -349,10 +349,10 @@ def schedule(self):
349349
return
350350

351351
# Determine chunks of work (scopes)
352-
unsorted_workqueue = OrderedDict()
352+
unsorted_workqueue = {}
353353
for nodeid in self.collection:
354354
scope = self._split_scope(nodeid)
355-
work_unit = unsorted_workqueue.setdefault(scope, default=OrderedDict())
355+
work_unit = unsorted_workqueue.setdefault(scope, {})
356356
work_unit[nodeid] = False
357357

358358
# Insert tests scopes into work queue ordered by number of tests.
@@ -368,7 +368,7 @@ def schedule(self):
368368
self.log(f"Shutting down {extra_nodes} nodes")
369369

370370
for _ in range(extra_nodes):
371-
unused_node, assigned = self.assigned_work.popitem(last=True)
371+
unused_node, assigned = self.assigned_work.popitem()
372372

373373
self.log(f"Shutting down unused node {unused_node}")
374374
unused_node.shutdown()

0 commit comments

Comments
 (0)