How to use check_worker_timed_out method in Slash

Best Python code snippet using slash

parallel_manager.py

Source:parallel_manager.py Github

copy

Full Screen

...73 if time.time() - self.server.start_time > config.root.parallel.worker_connect_timeout * self.workers_num:74 self.handle_error("Timeout: Not all clients connected to server, terminating.\n\75 Clients connected: {}".format(self.server.connected_clients))76 time.sleep(TIME_BETWEEN_CHECKS)77 def check_worker_timed_out(self):78 workers_last_connection_time = self.keepalive_server.get_workers_last_connection_time()79 for worker_id in self.server.get_connected_clients():80 worker_last_connection_time = workers_last_connection_time.get(worker_id, None)81 if worker_last_connection_time is None: #worker keepalive thread didn't started yet82 continue83 if time.time() - worker_last_connection_time > config.root.parallel.communication_timeout_secs:84 _logger.error("Worker {} is down, terminating session", worker_id, extra={'capture': False})85 self.report_worker_error_logs()86 self.workers[worker_id].handle_timeout()87 get_xmlrpc_proxy(config.root.parallel.server_addr, self.server.port).report_client_failure(worker_id)88 def check_no_requests_timeout(self):89 if time.time() - self.keepalive_server.last_request_time > config.root.parallel.no_request_timeout:90 _logger.error("No request sent to server for {} seconds, terminating",91 config.root.parallel.no_request_timeout, extra={'capture': False})92 if self.server.has_connected_clients():93 _logger.error("Clients that are still connected to server: {}",94 self.server.connected_clients, extra={'capture': False})95 if self.server.has_more_tests():96 _logger.error("Number of unstarted tests: {}", len(self.server.get_unstarted_tests()),97 extra={'capture': False})98 if self.server.executing_tests:99 _logger.error("Currently executed tests indexes: {}", self.server.executing_tests.values(),100 extra={'capture': False})101 self.handle_error("No request sent to server for {} seconds, terminating".format(config.root.parallel.no_request_timeout))102 def start(self):103 self.try_connect()104 try:105 for worker in list(self.workers.values()):106 worker.start()107 self.wait_all_workers_to_connect()108 while self.server.should_wait_for_request():109 self.check_worker_timed_out()110 self.check_no_requests_timeout()111 time.sleep(TIME_BETWEEN_CHECKS)112 except INTERRUPTION_EXCEPTIONS:113 _logger.error("Server interrupted, stopping workers and terminating", extra={'capture': False})114 get_xmlrpc_proxy(config.root.parallel.server_addr, self.server.port).session_interrupted()115 self.kill_workers()116 raise117 finally:118 for worker in list(self.workers.values()):119 worker.wait_to_finish()120 get_xmlrpc_proxy(config.root.parallel.server_addr, self.server.port).stop_serve()121 get_xmlrpc_proxy(config.root.parallel.server_addr, self.keepalive_server.port).stop_serve()122 self.server_thread.join()123 self.keepalive_server_thread.join()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful