mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-12-19 19:06:16 +01:00
4bb420d049
* Add service manager infrastructure The changes are (This will be a bit long): - A ServiceManager class that spawns a background thread and deals with service lifecycle management. The idea is that service lifecycle code will run in async functions, so a single thread is enough to manage any (reasonable) amount of services. - A Service class, that offers start(), stop() and restart() methods that simply notify the service manager to... well. Start, stop or restart a service. (!) Warning: Note that this differs from mp.Process.start/stop in that the service commands are sent asynchronously and will complete "eventually". This is good because it means that business logic is fast when booting up and shutting down, but we need to make sure that code does not rely on start() and stop() being instant (Mainly pid assignments). Subclasses of the Service class should use the on_start and on_stop methods to monitor for service events. These will be run by the service manager thread, so we need to be careful not to block execution here. Standard async stuff. (!) Note on service names: Service names should be unique within a ServiceManager. Make sure that you pass the name you want to super().__init__(name="...") if you plan to spawn multiple instances of a service. - A ServiceProcess class: A Service that wraps a multiprocessing.Process into a Service. It offers a run() method subclasses can override and can support in-place restarting using the service manager. And finally, I lied a bit about this whole thing using a single thread. I can't find any way to run python multiprocessing in async, so there is a MultiprocessingWaiter thread that waits for multiprocessing events and notifies any pending futures. This was uhhh... fun? No, not really. But it works. Using this part of the code just involves calling the provided wait method. See the implementation of ServiceProcess for more details. Mirror util.Process hooks onto service process Remove Service.__name attribute Do not serialize process object on ServiceProcess start. asd * Update frigate dictionary * Convert AudioProcessor to service process
66 lines
1.3 KiB
INI
66 lines
1.3 KiB
INI
[mypy]
|
|
python_version = 3.9
|
|
show_error_codes = true
|
|
follow_imports = normal
|
|
ignore_missing_imports = true
|
|
strict_equality = true
|
|
warn_incomplete_stub = true
|
|
warn_redundant_casts = true
|
|
warn_unused_configs = true
|
|
warn_unused_ignores = true
|
|
enable_error_code = ignore-without-code
|
|
check_untyped_defs = true
|
|
disallow_incomplete_defs = true
|
|
disallow_subclassing_any = true
|
|
# https://github.com/python/mypy/issues/10757
|
|
disallow_untyped_calls = false
|
|
disallow_untyped_decorators = true
|
|
disallow_untyped_defs = true
|
|
no_implicit_optional = true
|
|
warn_return_any = true
|
|
warn_unreachable = true
|
|
no_implicit_reexport = true
|
|
|
|
[mypy-frigate.*]
|
|
ignore_errors = true
|
|
|
|
[mypy-frigate.__main__]
|
|
ignore_errors = false
|
|
disallow_untyped_calls = false
|
|
|
|
[mypy-frigate.app]
|
|
ignore_errors = false
|
|
disallow_untyped_calls = false
|
|
|
|
[mypy-frigate.const]
|
|
ignore_errors = false
|
|
|
|
[mypy-frigate.events]
|
|
ignore_errors = false
|
|
|
|
[mypy-frigate.log]
|
|
ignore_errors = false
|
|
|
|
[mypy-frigate.models]
|
|
ignore_errors = false
|
|
|
|
[mypy-frigate.plus]
|
|
ignore_errors = false
|
|
|
|
[mypy-frigate.stats]
|
|
ignore_errors = false
|
|
|
|
[mypy-frigate.types]
|
|
ignore_errors = false
|
|
|
|
[mypy-frigate.version]
|
|
ignore_errors = false
|
|
|
|
[mypy-frigate.watchdog]
|
|
ignore_errors = false
|
|
disallow_untyped_calls = false
|
|
|
|
|
|
[mypy-frigate.service_manager.*]
|
|
ignore_errors = false
|