@@ -46,9 +46,8 @@ def __init__(self, config):
4646 self ._failed_collection_errors = {}
4747 self ._active_nodes = set ()
4848 self ._failed_nodes_count = 0
49- self ._max_worker_restart = self .config .option .maxworkerrestart
50- if self ._max_worker_restart is not None :
51- self ._max_worker_restart = int (self ._max_worker_restart )
49+ self ._max_worker_restart = get_default_max_worker_restart (self .config )
50+
5251 try :
5352 self .terminal = config .pluginmanager .getplugin ("terminalreporter" )
5453 except KeyError :
@@ -390,10 +389,16 @@ def pytest_testnodedown(self, node, error):
390389 return
391390 self .write_line ("[%s] node down: %s" % (node .gateway .id , error ))
392391
393- # def pytest_xdist_rsyncstart(self, source, gateways):
394- # targets = ",".join([gw.id for gw in gateways])
395- # msg = "[%s] rsyncing: %s" %(targets, source)
396- # self.write_line(msg)
397- # def pytest_xdist_rsyncfinish(self, source, gateways):
398- # targets = ", ".join(["[%s]" % gw.id for gw in gateways])
399- # self.write_line("rsyncfinish: %s -> %s" %(source, targets))
392+
393+ def get_default_max_worker_restart (config ):
394+ """gets the default value of --max-worker-restart option if it is not provided.
395+
396+ Use a reasonable default to avoid workers from restarting endlessly due to crashing collections (#226).
397+ """
398+ result = config .option .maxworkerrestart
399+ if result is not None :
400+ result = int (result )
401+ elif config .option .numprocesses :
402+ # if --max-worker-restart was not provided, use a reasonable default (#226)
403+ result = config .option .numprocesses * 4
404+ return result
0 commit comments