Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions appdaemon/adapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,11 +979,11 @@ async def set_production_mode(self, mode: bool = True) -> bool | None:
The specified mode or ``None`` if a wrong parameter is passed.

"""
if not isinstance(mode, bool):
if isinstance(mode, bool):
self.AD.production_mode = mode
return mode
else:
self.logger.warning("%s not a valid parameter for Production Mode", mode)
return
await self.AD.utility.set_production_mode(mode)
return mode

#
# Internal Helper functions
Expand Down
7 changes: 6 additions & 1 deletion appdaemon/appdaemon.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import os.path
import threading
from asyncio import BaseEventLoop
from concurrent.futures import ThreadPoolExecutor
Expand Down Expand Up @@ -276,6 +275,12 @@ def namespaces(self):
def production_mode(self):
return self.config.production_mode

@production_mode.setter
def production_mode(self, mode: bool):
self.config.production_mode = mode
action = "activated" if mode else "deactivated"
self.logger.info("AD Production Mode %s", action)

@property
def qsize_warning_iterations(self):
return self.config.qsize_warning_iterations
Expand Down
15 changes: 5 additions & 10 deletions appdaemon/utility_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,11 @@ async def loop(self):
if self.AD.http is not None:
await self.AD.http.stop_server()

async def set_production_mode(self, mode: bool = True):
if mode is True:
self.logger.info("AD Production Mode Activated")
else:
self.logger.info("AD Production Mode Deactivated")
self.AD.production_mode = mode

async def production_mode_service(self, ns, domain, service, kwargs):
if "mode" in kwargs:
mode = kwargs["mode"]
await self.set_production_mode(mode)
if mode := kwargs.get("mode"):
if isinstance(mode, bool):
self.AD.production_mode = mode
else:
self.logger.warning("Invalid 'mode' specified in service call")
else:
self.logger.warning("'Mode' not specified in service call")
Loading