How to use _master_release method in autotest

Best Python code snippet using autotest_python

barrier.py

Source:barrier.py Github

copy

Full Screen

...230 logging.info("slave now waiting: (%s:%d)", addr[0], addr[1])231 # They seem to be valid record them.232 self._waiting[self._hostid] = connection233 self._seen = 1234 def _master_release(self):235 # Check everyone is still there, that they have not236 # crashed or disconnected in the meantime.237 allpresent = True238 abort = self._abort239 for name in self._waiting:240 (client, addr) = self._waiting[name]241 logging.info("checking client present: %s", name)242 client.settimeout(5)243 reply = 'none'244 try:245 client.send("ping")246 reply = client.recv(1024)247 except socket.timeout:248 logging.warning("ping/pong timeout: %s", name)249 pass250 if reply == 'abrt':251 logging.warning("Client %s requested abort", name)252 abort = True253 elif reply != "pong":254 allpresent = False255 if not allpresent:256 raise error.BarrierError("master lost client")257 if abort:258 logging.info("Aborting the clients")259 msg = 'abrt'260 else:261 logging.info("Releasing clients")262 msg = 'rlse'263 # If every ones checks in then commit the release.264 for name in self._waiting:265 (client, addr) = self._waiting[name]266 client.settimeout(5)267 try:268 client.send(msg)269 except socket.timeout:270 logging.warning("release timeout: %s", name)271 pass272 if abort:273 raise BarrierAbortError("Client requested abort")274 def _waiting_close(self):275 # Either way, close out all the clients. If we have276 # not released them then they know to abort.277 for name in self._waiting:278 (client, addr) = self._waiting[name]279 logging.info("closing client: %s", name)280 try:281 client.close()282 except:283 pass284 def _run_server(self, is_master):285 server = self._server or listen_server(port=self._port)286 failed = 0287 try:288 while True:289 try:290 # Wait for callers welcoming each.291 server.socket.settimeout(self._remaining())292 connection = server.socket.accept()293 if is_master:294 self._master_welcome(connection)295 else:296 self._slave_hello(connection)297 except socket.timeout:298 logging.warning("timeout waiting for remaining clients")299 pass300 if is_master:301 # Check if everyone is here.302 logging.info("master seen %d of %d",303 self._seen, len(self._members))304 if self._seen == len(self._members):305 self._master_release()306 break307 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....

Full Screen

Full Screen

base_barrier.py

Source:base_barrier.py Github

copy

Full Screen

...230 logging.info("slave now waiting: (%s:%d)", addr[0], addr[1])231 # They seem to be valid record them.232 self._waiting[self._hostid] = connection233 self._seen = 1234 def _master_release(self):235 # Check everyone is still there, that they have not236 # crashed or disconnected in the meantime.237 allpresent = True238 abort = self._abort239 for name in self._waiting:240 (client, addr) = self._waiting[name]241 logging.info("checking client present: %s", name)242 client.settimeout(5)243 reply = 'none'244 try:245 client.send("ping")246 reply = client.recv(1024)247 except socket.timeout:248 logging.warning("ping/pong timeout: %s", name)249 pass250 if reply == 'abrt':251 logging.warning("Client %s requested abort", name)252 abort = True253 elif reply != "pong":254 allpresent = False255 if not allpresent:256 raise error.BarrierError("master lost client")257 if abort:258 logging.info("Aborting the clients")259 msg = 'abrt'260 else:261 logging.info("Releasing clients")262 msg = 'rlse'263 # If every ones checks in then commit the release.264 for name in self._waiting:265 (client, addr) = self._waiting[name]266 client.settimeout(5)267 try:268 client.send(msg)269 except socket.timeout:270 logging.warning("release timeout: %s", name)271 pass272 if abort:273 raise BarrierAbortError("Client requested abort")274 def _waiting_close(self):275 # Either way, close out all the clients. If we have276 # not released them then they know to abort.277 for name in self._waiting:278 (client, addr) = self._waiting[name]279 logging.info("closing client: %s", name)280 try:281 client.close()282 except:283 pass284 def _run_server(self, is_master):285 server = self._server or listen_server(port=self._port)286 failed = 0287 try:288 while True:289 try:290 # Wait for callers welcoming each.291 server.socket.settimeout(self._remaining())292 connection = server.socket.accept()293 if is_master:294 self._master_welcome(connection)295 else:296 self._slave_hello(connection)297 except socket.timeout:298 logging.warning("timeout waiting for remaining clients")299 pass300 if is_master:301 # Check if everyone is here.302 logging.info("master seen %d of %d",303 self._seen, len(self._members))304 if self._seen == len(self._members):305 self._master_release()306 break307 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....

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 autotest 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