If you expect an exception to be raised in your message handlers. You
need to handle that with a "try/except" yourself, like this:
class Play(Actor):
subscriptions = ['BombMessage']
def handle_BombMessage(self, msg):
try:
# do something with the bomb
pass
exception Exception, e:
print "oops"
If you want to catch when a child group had failed, on your main
group's "tick", you can catch for a "GroupFailed" exception. Then you
can do the appropriate removing of the group and re-enabling it.
so in your main group, something like:
while True:
try:
mgr.tick()
except GroupFailed, e:
# remove your group and re-enable it
pass
There is a unit test that tests for this exception to be raised in
here (line 132):
http://code.google.com/p/pysage/source/browse/trunk/tests/test_groups_process.py#132
Does that help?
John
> --
> You received this message because you are subscribed to the Google Groups "pysage" group.
> To post to this group, send email to pys...@googlegroups.com.
> To unsubscribe from this group, send email to pysage+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pysage?hl=en.
>
>
Jay:
handlers are dispatched via "handle_message". If you want to
implement a "catch all", you could do something like this:
class Play(Actor):
subscriptions = ['BombMessage']
def handle_message(self, msg):
try:
Actor.handle_message(self, msg)
except Exception, e:
print e
> And how to catch the exceptions in the
> MainGroup. So if a ClientGroup dies then i do the following????
>
> try
> mgr.tick()
> except GroupFailed e:
> mgr.remove_process_group(name) # Do we have the group name
> mgr.add_process_group(name,Class)
Please update to pysage 1.5.5-1.
I added the ability to inspect the group's name on exception. See
http://code.google.com/p/pysage/source/browse/trunk/tests/test_groups_process.py#140
Let me know if that helps.
I added the ability to inspect the group's name on exception. See
http://code.google.com/p/pysage/source/browse/trunk/tests/test_groups_process.py#140