Skip to content

Commit

Permalink
Merge pull request #481 from TeskaLabs/fix/library-set
Browse files Browse the repository at this point in the history
ASAB Library: Allow set in `.disabled.yaml`
  • Loading branch information
ateska authored Aug 29, 2023
2 parents a3ec0c2 + 02558ab commit a5bd742
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions asab/library/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ def __init__(self, app: Application, service_name: str, paths: typing.Union[str,
for layer, path in enumerate(paths):
# Create library for each layer of paths
self._create_library(path, layer)
app.PubSub.subscribe("Application.tick/60!", self._on_tick)
app.PubSub.subscribe("Application.tick/60!", self._on_tick60)

async def finalize(self, app):
while len(self.Libraries) > 0:
lib = self.Libraries.pop(-1)
await lib.finalize(self.App)

async def _on_tick(self, message_type):
async def _on_tick60(self, message_type):
await self._read_disabled()

def _create_library(self, path, layer):
Expand Down Expand Up @@ -287,6 +287,9 @@ async def _read_disabled(self):
self.Disabled = yaml.safe_load(disabled)
if self.Disabled is None:
self.Disabled = {}
elif isinstance(self.Disabled, set):
# This is for a backward compatibility (Aug 2023)
self.Disabled = {key: '*' for key in self.Disabled}
else:
# Disabled must be a dictionary object
assert (isinstance(self.Disabled, dict)), "The 'Disabled' attribute must be a dictionary instance."
Expand Down

0 comments on commit a5bd742

Please sign in to comment.