Best Python code snippet using autotest_python
barrier.py
Source:barrier.py
...307 else:308 # Check if master connected.309 if self._seen:310 logging.info("slave connected to master")311 self._slave_wait()312 break313 finally:314 self._waiting_close()315 # if we created the listening_server in the beginning of this316 # function then close the listening socket here317 if not self._server:318 server.close()319 def _run_client(self, is_master):320 while self._remaining() is None or self._remaining() > 0:321 try:322 remote = socket.socket(socket.AF_INET,323 socket.SOCK_STREAM)324 remote.settimeout(30)325 if is_master:326 # Connect to all slaves.327 host = _get_host_from_id(self._members[self._seen])328 logging.info("calling slave: %s", host)329 connection = (remote, (host, self._port))330 remote.connect(connection[1])331 self._master_welcome(connection)332 else:333 # Just connect to the master.334 host = _get_host_from_id(self._masterid)335 logging.info("calling master")336 connection = (remote, (host, self._port))337 remote.connect(connection[1])338 self._slave_hello(connection)339 except socket.timeout:340 logging.warning("timeout calling host, retry")341 sleep(10)342 pass343 except socket.error, err:344 (code, str) = err345 if (code != errno.ECONNREFUSED and346 code != errno.ETIMEDOUT):347 raise348 sleep(10)349 if is_master:350 # Check if everyone is here.351 logging.info("master seen %d of %d",352 self._seen, len(self._members))353 if self._seen == len(self._members):354 self._master_release()355 break356 else:357 # Check if master connected.358 if self._seen:359 logging.info("slave connected to master")360 self._slave_wait()361 break362 self._waiting_close()363 def _slave_wait(self):364 remote = self._waiting[self._hostid][0]365 mode = "wait"366 while True:367 # All control messages are the same size to allow368 # us to split individual messages easily.369 remote.settimeout(self._remaining())370 reply = remote.recv(4)371 if not reply:372 break373 reply = reply.strip("\r\n")374 logging.info("master said: %s", reply)375 mode = reply376 if reply == "ping":377 # Ensure we have sufficient time for the...
base_barrier.py
Source:base_barrier.py
...307 else:308 # Check if master connected.309 if self._seen:310 logging.info("slave connected to master")311 self._slave_wait()312 break313 finally:314 self._waiting_close()315 # if we created the listening_server in the beginning of this316 # function then close the listening socket here317 if not self._server:318 server.close()319 def _run_client(self, is_master):320 while self._remaining() is None or self._remaining() > 0:321 try:322 remote = socket.socket(socket.AF_INET,323 socket.SOCK_STREAM)324 remote.settimeout(30)325 if is_master:326 # Connect to all slaves.327 host = get_host_from_id(self._members[self._seen])328 logging.info("calling slave: %s", host)329 connection = (remote, (host, self._port))330 remote.connect(connection[1])331 self._master_welcome(connection)332 else:333 # Just connect to the master.334 host = get_host_from_id(self._masterid)335 logging.info("calling master")336 connection = (remote, (host, self._port))337 remote.connect(connection[1])338 self._slave_hello(connection)339 except socket.timeout:340 logging.warning("timeout calling host, retry")341 sleep(10)342 pass343 except socket.error, err:344 (code, str) = err345 if (code != errno.ECONNREFUSED):346 raise347 sleep(10)348 if is_master:349 # Check if everyone is here.350 logging.info("master seen %d of %d",351 self._seen, len(self._members))352 if self._seen == len(self._members):353 self._master_release()354 break355 else:356 # Check if master connected.357 if self._seen:358 logging.info("slave connected to master")359 self._slave_wait()360 break361 self._waiting_close()362 def _slave_wait(self):363 remote = self._waiting[self._hostid][0]364 mode = "wait"365 while True:366 # All control messages are the same size to allow367 # us to split individual messages easily.368 remote.settimeout(self._remaining())369 reply = remote.recv(4)370 if not reply:371 break372 reply = reply.strip("\r\n")373 logging.info("master said: %s", reply)374 mode = reply375 if reply == "ping":376 # Ensure we have sufficient time for the...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!