How to use shutdown_scheduler method in localstack

Best Python code snippet using localstack_python

musicbox.py

Source:musicbox.py Github

copy

Full Screen

1from folderHandler import FolderHandler2from rfidReader import RFIDReader3from mp3Player import MP3Player4from speakerHandler import SpeakerHandler5from buttonHandler import ButtonHandler6from importer import Importer7from settings import Settings8from ledHandler import LedHandler9from shutdownScheduler import ShutdownScheduler10import signal11import sys12# some base definitions13base_path = "/home/pi/musicbox/"14music_path = base_path + "music"15shutdown_time = 30 # shutdown after 30 minutes16# instanciate all classes17settings = Settings(base_path)18speaker_handler = SpeakerHandler()19mp3_player = MP3Player(music_path, settings, speaker_handler)20button_handler = ButtonHandler(mp3_player)21folder_handler = FolderHandler(music_path)22importer = Importer(music_path)23rfid_reader = RFIDReader()24led_handler = LedHandler()25shutdown_scheduler = ShutdownScheduler(mp3_player, shutdown_time, speaker_handler)26# define the exit handler to switch off speaker and antenna27def exit_handler(signum=None, frame=None):28 shutdown_scheduler.shutdown()29 speaker_handler.speaker_off()30 rfid_reader.antenna_off()31 led_handler.shutdown()32 sys.exit(0)33for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]:34 signal.signal(sig, exit_handler)35# start main loop that waits for tags36tag = ""37while True:38 tag = rfid_reader.wait_for_tag_change(tag)39 if tag == "":40 print(tag + " removed.")41 mp3_player.pause()42 else:43 print(str(tag) + " detected.")44 folder = folder_handler.get_folder_by_tag(tag)45 if folder != "":46 mp3_player.play(folder)47 else:48 print("Tag is new...")49 if importer.new_music_available():50 print("New music for import found.")51 folder = str(tag)52 importer.import_new_music(folder)53 mp3_player.play(folder)54 else:...

Full Screen

Full Screen

test_server.py

Source:test_server.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# vim: set ft=python ts=4 sw=4 expandtab:3from unittest.mock import patch4import pytest5from fastapi.testclient import TestClient6from vplan.engine.server import API, API_VERSION, shutdown_event, startup_event7CLIENT = TestClient(API)8class TestLifecycle:9 pytestmark = pytest.mark.asyncio10 @patch("vplan.engine.server.start_scheduler")11 @patch("vplan.engine.server.setup_database")12 @patch("vplan.engine.server.setup_directories")13 async def test_startup_event(self, setup_directories, setup_database, start_scheduler):14 await startup_event()15 setup_directories.assert_called_once()16 setup_database.assert_called_once()17 start_scheduler.assert_called_once()18 @patch("vplan.engine.server.shutdown_scheduler")19 async def test_shutdown_event(self, shutdown_scheduler):20 await shutdown_event()21 shutdown_scheduler.assert_called_once()22class TestRoutes:23 def test_health(self):24 response = CLIENT.get(url="/health")25 assert response.status_code == 20026 assert response.json() == {"status": "OK"}27 @patch("vplan.engine.server.metadata_version")28 def test_version(self, metadata_version):29 metadata_version.return_value = "xxx"30 response = CLIENT.get(url="/version")31 assert response.status_code == 200...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1import atexit2from flask import Flask3from rest_app.shared import db, scheduler4from rest_app.views.shared import blueprint as views_blueprint5from rest_app.services import refresh_offers6def create_app(start_background_job=True, shutdown_scheduler=True, **kwargs) -> Flask:7 app = Flask(__name__)8 app.config.from_pyfile('config.py')9 app.config.update(**kwargs)10 db.init_app(app)11 app.register_blueprint(views_blueprint)12 if start_background_job:13 scheduler.init_app(app)14 with app.app_context():15 db.create_all()16 refresh_offers.schedule_refresh()17 if start_background_job:18 scheduler.start()19 if shutdown_scheduler:20 atexit.register(scheduler.shutdown)...

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