Skip to content

Commit

Permalink
fixup! WIP: support async coroutine functions
Browse files Browse the repository at this point in the history
  • Loading branch information
spaceone committed Dec 31, 2022
1 parent 6f5cc8c commit e50971b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions circuits/core/handlers.py
@@ -1,6 +1,7 @@
"""
This module define the @handler decorator/function and the HandlesType type.
"""
import inspect
from collections.abc import Callable

from circuits.tools import getargspec
Expand Down Expand Up @@ -63,6 +64,7 @@ def handler(*names, **kwargs):
"""

def wrapper(f):
assert inspect.iscoroutinefunction(f)
if names and isinstance(names[0], bool) and not names[0]:
f.handler = False
return f
Expand Down
3 changes: 2 additions & 1 deletion circuits/core/workers.py
Expand Up @@ -82,5 +82,6 @@ async def _on_stopped(self, event, *args):
@handler("task")
async def _on_task(self, f, *args, **kwargs):
result = self.pool.apply_async(f, args, kwargs)
await result.ready()
while not result.ready():
await
return result.get()

0 comments on commit e50971b

Please sign in to comment.