[Pytest-commit] commit/pytest-xdist: hpk42: refine distribution fractions and make it dependend on the duration

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Jan 27 12:39:53 CET 2014


1 new commit in pytest-xdist:

https://bitbucket.org/hpk42/pytest-xdist/commits/5be06b2a6411/
Changeset:   5be06b2a6411
User:        hpk42
Date:        2014-01-27 12:39:43
Summary:     refine distribution fractions and make it dependend on the duration
of the last test in a node's set.
Affected #:  1 file

diff -r 05aa4f48306c905ae4d183a4b337f63cc4490466 -r 5be06b2a6411b5ac468556932861c01b21bbb107 xdist/dsession.py
--- a/xdist/dsession.py
+++ b/xdist/dsession.py
@@ -40,7 +40,7 @@
         if len(self.node2pending) >= self.numnodes:
             self.collection_is_completed = True
 
-    def remove_item(self, node, item_index):
+    def remove_item(self, node, item_index, duration=0):
         self.node2pending[node].remove(item_index)
 
     def remove_node(self, node):
@@ -91,12 +91,16 @@
         if len(self.node2collection) >= self.numnodes:
             self.collection_is_completed = True
 
-    def remove_item(self, node, item_index):
+    def remove_item(self, node, item_index, duration=0):
         node_pending = self.node2pending[node]
         node_pending.remove(item_index)
         # pre-load items-to-test if the node may become ready
 
         if self.pending:
+            if duration >= 0.1 and node_pending:
+                # seems the node is doing long-running tests
+                # so let's rather wait with sending new items
+                return
             # how many nodes do we have remaining per node roughly?
             num_nodes = len(self.node2pending)
             # if our node goes below a heuristic minimum, fill it out to
@@ -142,8 +146,8 @@
             return
         # how many items per node do we have about?
         items_per_node = len(self.collection) // len(self.node2pending)
-        # take half of it for initial distribution, at least 1
-        node_chunksize = max(items_per_node // 2, 1)
+        # take a fraction of tests for initial distribution
+        node_chunksize = max(items_per_node // 4, 1)
         # and initialize each node with a chunk of tests
         for node in self.node2pending:
             self._send_tests(node, node_chunksize)
@@ -317,7 +321,7 @@
     def slave_testreport(self, node, rep):
         if not (rep.passed and rep.when != "call"):
             if rep.when in ("setup", "call"):
-                self.sched.remove_item(node, rep.item_index)
+                self.sched.remove_item(node, rep.item_index, rep.duration)
         #self.report_line("testreport %s: %s" %(rep.id, rep.status))
         rep.node = node
         self.config.hook.pytest_runtest_logreport(report=rep)

Repository URL: https://bitbucket.org/hpk42/pytest-xdist/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the pytest-commit mailing list