Skip to content

Commit

Permalink
Added spinoff.actor.quick.{actor, process}
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Allik committed Oct 4, 2013
1 parent 10b5386 commit 2d7d6d5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spinoff/actor/__init__.py
Expand Up @@ -6,6 +6,7 @@
from .props import Props
from .exceptions import Unhandled
from .spin import spin
from .quick import actor, process


__all__ = [Actor, spawn, Node, Uri, Props, Unhandled, spin]
__all__ = [Actor, spawn, Node, Uri, Props, Unhandled, spin, actor, process]
25 changes: 25 additions & 0 deletions spinoff/actor/quick.py
@@ -0,0 +1,25 @@
from spinoff.actor import Actor


def actor(fn):
class Ret(Actor):
def receive(self, message):
return fn(self, message)

# Ret.__doc__ = fn.__doc__ # XXX: not allowed for some reason
Ret.__module__ = fn.__module__
Ret.__name__ = fn.__name__

return Ret


def process(fn):
class Ret(Actor):
def run(self, *args, **kwargs):
return fn(self, *args, **kwargs)

# Ret.__doc__ = fn.__doc__ # XXX: not allowed for some reason
Ret.__module__ = fn.__module__
Ret.__name__ = fn.__name__

return Ret

0 comments on commit 2d7d6d5

Please sign in to comment.