How to use _trigger_stop method in localstack

Best Python code snippet using localstack_python

conftest.py

Source:conftest.py Github

copy

Full Screen

...53 localstack_started.wait()54@pytest.hookimpl()55def pytest_unconfigure(config):56 # last pytest lifecycle hook (before pytest exits)57 _trigger_stop()58def _start_monitor():59 threading.Thread(target=startup_monitor).start()60def _trigger_stop():61 localstack_stop.set()62 startup_monitor_event.set()63def startup_monitor() -> None:64 """65 The startup monitor is a thread that waits for the startup_monitor_event and, once the event is true, starts a66 localstack instance in it's own thread context.67 """68 logger.info("waiting on localstack_start signal")69 startup_monitor_event.wait()70 if localstack_stop.is_set():71 # this is called if _trigger_stop() is called before any test has requested the localstack_runtime fixture.72 logger.info("ending startup_monitor")73 localstack_stopped.set()74 return75 if is_env_true("TEST_SKIP_LOCALSTACK_START") or os.environ.get("TEST_TARGET") == "AWS_CLOUD":76 logger.info("TEST_SKIP_LOCALSTACK_START is set, not starting localstack")77 localstack_started.set()78 return79 logger.info("running localstack")80 run_localstack()81def run_localstack():82 """83 Start localstack and block until it terminates. Terminate localstack by calling _trigger_stop().84 """85 # configure86 os.environ[ENV_INTERNAL_TEST_RUN] = "1"87 safe_requests.verify_ssl = False88 config.FORCE_SHUTDOWN = False89 config.EDGE_BIND_HOST = "0.0.0.0"90 def watchdog():91 logger.info("waiting stop event")92 localstack_stop.wait() # triggered by _trigger_stop()93 logger.info("stopping infra")94 infra.stop_infra()95 monitor = threading.Thread(target=watchdog)96 monitor.start()97 logger.info("starting localstack infrastructure")98 infra.start_infra(asynchronous=True)99 for fn in test_init_functions:100 try:101 # asynchronous init functions102 fn()103 except Exception:104 logger.exception("exception while running init function for test")105 logger.info("waiting for infra to be ready")106 infra.INFRA_READY.wait() # wait for infra to start (threading event)...

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