Best Python code snippet using locust
test_runners.py
Source:test_runners.py  
...285        env = Environment()286        runner = env.create_local_runner()287        self.assertEqual(env, runner.environment)288        self.assertEqual(runner, env.runner)289    def test_users_can_call_runner_quit_without_deadlocking(self):290        class BaseUser(User):291            stop_triggered = False292            @task293            def trigger(self):294                self.environment.runner.quit()295            def on_stop(self):296                BaseUser.stop_triggered = True297        runner = Environment(user_classes=[BaseUser]).create_local_runner()298        runner.spawn_users(1, 1, wait=False)299        timeout = gevent.Timeout(0.5)300        timeout.start()301        try:302            runner.greenlet.join()303        except gevent.Timeout:...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!!
