Skip to content

Commit

Permalink
do some core components with async functions?
Browse files Browse the repository at this point in the history
  • Loading branch information
spaceone committed Dec 31, 2022
1 parent 0bd6765 commit 6adc8dc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions circuits/core/manager.py
Expand Up @@ -504,7 +504,7 @@ def unregisterTask(self, g):
if g in self.root._tasks:
self.root._tasks.remove(g)

def waitEvent(self, event, *channels, **kwargs): # noqa
async def waitEvent(self, event, *channels, **kwargs): # noqa
# XXX: C901: This has a high McCabe complexity score of 16.
# TODO: Refactor this method.

Expand Down Expand Up @@ -567,7 +567,7 @@ def _on_tick(self):

wait = waitEvent

def callEvent(self, event, *channels, **kwargs):
async def callEvent(self, event, *channels, **kwargs):
"""
Fire the given event to the specified channels and suspend
execution until it has been dispatched. This method may only
Expand All @@ -578,8 +578,9 @@ def callEvent(self, event, *channels, **kwargs):
been dispatched (see :func:`circuits.core.handlers.handler`).
"""
value = self.fire(event, *channels)
yield from self.waitEvent(event, *event.channels, **kwargs)
yield CallValue(value)
async for r in self.waitEvent(event, *event.channels, **kwargs):
await r # pass ?
return CallValue(value)

call = callEvent

Expand Down Expand Up @@ -865,7 +866,9 @@ def processTask(self, event, task, parent=None): # noqa
if parent:
value = parent.throw(value.extract())
if value is not None:
value_generator = (val for val in (value,))
async def value_generator():
return value # yield?
# value_generator = (val for val in (value,))
self.registerTask((event, value_generator, parent))
else:
raise value.extract()
Expand Down

0 comments on commit 6adc8dc

Please sign in to comment.