1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-26 21:14:19 +00:00

📰 Log dispenser actions

This commit is contained in:
Steffo 2020-12-28 17:58:41 +01:00
parent 69f50138ef
commit a79fc91b10

View file

@ -26,7 +26,7 @@ class Dispenser:
:param item: The item to insert. :param item: The item to insert.
""" """
log.debug(f"Putting {item}") log.debug(f"Putting {item}...")
for sentry in self.sentries: for sentry in self.sentries:
await sentry.put(item) await sentry.put(item)
@ -36,11 +36,16 @@ class Dispenser:
A context manager which creates a :class:`.SentrySource` and keeps it in :attr:`.sentries` while it is being A context manager which creates a :class:`.SentrySource` and keeps it in :attr:`.sentries` while it is being
used. used.
""" """
log.debug("Creating a new SentrySource...")
sentry = SentrySource(dispenser=self, *args, **kwargs) sentry = SentrySource(dispenser=self, *args, **kwargs)
log.debug(f"Adding: {sentry}")
self.sentries.append(sentry) self.sentries.append(sentry)
log.debug(f"Yielding: {sentry}")
yield sentry yield sentry
log.debug(f"Removing from the sentries list: {sentry}")
self.sentries.remove(sentry) self.sentries.remove(sentry)
async def run(self, conv: t.Conversation) -> None: async def run(self, conv: t.Conversation) -> None:
@ -49,11 +54,13 @@ class Dispenser:
:param conv: The conversation to run. :param conv: The conversation to run.
""" """
log.debug(f"Running: {conv}")
with self.sentry() as sentry: with self.sentry() as sentry:
state = conv(_sentry=sentry) state = conv(_sentry=sentry)
log.debug(f"First state: {state}")
while state := await state: while state := await state:
pass log.debug(f"Switched to: {state}")
__all__ = ( __all__ = (