Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added spinoff.actor.quick.{actor, process}
- Loading branch information
Erik Allik
committed
Oct 4, 2013
1 parent
10b5386
commit 2d7d6d5
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |