Behaviors

28 views
Skip to first unread message

Richard Wells

unread,
Apr 11, 2018, 1:16:50 PM4/11/18
to thespian.py
Hi.

Any plans in the works to add behaviors to Thespian?  Similar to Akka or Akka.net.

Thanks,

Rick

Kevin Quick

unread,
Apr 11, 2018, 1:48:57 PM4/11/18
to Richard Wells, thespian.py
Hi Rick,

There are no current plans to implement a Behaviors analog, primarily because this hasn't been requested.  If there is enough interest, this concept could be explored as a future addition to Thespian.

In Akka, the behavior essentially determines a state of the Actor that is used to guide the handling of the next message(s).  This can currently be achieved in Thespian by directly expressing state:


    class MyActor(Actor):
        def __init__(self, *args, **kw):
            super(MyActor, self).__init__(*args, **kw)
            self.mystate = 0

        def receive_Message(self, msg, sender):
            if self.mystate == 0:
                .... handling in state 0
            elif self.mystate == 1:
                .... handling in state 1
            ...

The equivalent to Akka's `Behaviors.stopped` is `self.send(self.myaddress, ActorExitRequest())`, and the Akka `Behaviors.setup` is handled by the `__init__()` method for the Actor.

If you see additional benefits to implementing Behaviors in Thespian (and especially if I've missed some aspects of their Akka implementation) please let me know: I'm not opposed to extending Thespian to support them but would like to make sure the additional feature benefit outweighs the additional complexity.

Regards,
   Kevin


--
You received this message because you are subscribed to the Google Groups "thespian.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thespianpy+unsubscribe@googlegroups.com.
To post to this group, send email to thesp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/thespianpy/c513760e-9ffc-486b-a5d0-228ddc7196d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-KQ

Richard Wells

unread,
Apr 11, 2018, 1:55:57 PM4/11/18
to thespian.py
Thanks Kevin,

If I'm the only one requesting it then it's probably not worth implementing.  But I tell you, once a developer uses behaviors, I believe that they'll gain a great appreciation for them in defining state machines within actors.  But in the mean time I'll use your suggestion.

Thanks for the quick reply.

Rick

Kevin Quick

unread,
Apr 11, 2018, 2:05:23 PM4/11/18
to Richard Wells, thespian.py
Hi Rick,

The state machine aspect may be interesting to explore re: behaviors.  One issue I've often run into though in adding state to Actors is that the state tends to conflict with the ability to restart or scale out the number of actors (e.g. the troupe functionality).  How have you handled these types of issues in your Actor state machine implementations?

Regards,
  Kevin


--
You received this message because you are subscribed to the Google Groups "thespian.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thespianpy+unsubscribe@googlegroups.com.
To post to this group, send email to thesp...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
-KQ
Reply all
Reply to author
Forward
0 new messages