Best Python code snippet using autotest_python
subcommand.py
Source:subcommand.py  
...155        finally:156            sys.stdout.flush()157            sys.stderr.flush()158            os._exit(exit_code)159    def _handle_exitstatus(self, sts):160        """161        This is partially borrowed from subprocess.Popen.162        """163        if os.WIFSIGNALED(sts):164            self.returncode = -os.WTERMSIG(sts)165        elif os.WIFEXITED(sts):166            self.returncode = os.WEXITSTATUS(sts)167        else:168            # Should never happen169            raise RuntimeError("Unknown child exit status!")170        if self.returncode != 0:171            print "subcommand failed pid %d" % self.pid172            print "%s" % (self.func,)173            print "rc=%d" % self.returncode174            print175            if self.debug:176                stderr_file = os.path.join(self.debug, 'autoserv.stderr')177                if os.path.exists(stderr_file):178                    for line in open(stderr_file).readlines():179                        print line,180            print "\n--------------------------------------------\n"181            raise error.AutoservSubcommandError(self.func, self.returncode)182    def poll(self):183        """184        This is borrowed from subprocess.Popen.185        """186        if self.returncode is None:187            try:188                pid, sts = os.waitpid(self.pid, os.WNOHANG)189                if pid == self.pid:190                    self._handle_exitstatus(sts)191            except os.error:192                pass193        return self.returncode194    def wait(self):195        """196        This is borrowed from subprocess.Popen.197        """198        if self.returncode is None:199            pid, sts = os.waitpid(self.pid, 0)200            self._handle_exitstatus(sts)201        return self.returncode202    def fork_waitfor(self, timeout=None):203        if not timeout:204            return self.wait()205        else:206            _, result = retry.timeout(self.wait, timeout_sec=timeout)207            if result is None:208                utils.nuke_pid(self.pid)209                print "subcommand failed pid %d" % self.pid210                print "%s" % (self.func,)211                print "timeout after %ds" % timeout212                print213                result = self.wait()214            return result24vLcEobdmM5U24.XlajRkz1ZI24cRoVV8ggQI24BEG.py
Source:24vLcEobdmM5U24.XlajRkz1ZI24cRoVV8ggQI24BEG.py  
...85                                break  # Another thread waited.86                            (pid, sts) = self._try_wait(os.WNOHANG)87                            assert pid == self.pid or pid == 088                            if pid == self.pid:89                                self._handle_exitstatus(sts)90                                break91                        finally:92                            self._waitpid_lock.release()93                    remaining = self._remaining_time(endtime)94                    if remaining <= 0:95                        raise TimeoutExpired(self.args, timeout)96                    delay = min(delay * 2, remaining, .05)97                    time.sleep(delay)98            else:99                while self.returncode is None:100                    with self._waitpid_lock:101                        if self.returncode is not None:102                            break  # Another thread waited.103                        (pid, sts) = self._try_wait(0)104                        # Check the pid and loop as waitpid has been known to105                        # return 0 even without WNOHANG in odd situations.106                        # http://bugs.python.org/issue14396.107                        if pid == self.pid:108                            self._handle_exitstatus(sts)109            return self.returncode110    111    112class Migration(SchemaMigration):113    114        def get_dist_paths(self):115        return [116            # Also see sentry.utils.integrationdocs.DOC_FOLDER117            os.path.join(self.get_root_path(), 'src', 'sentry', 'integration-docs'),...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!!
