Skip to content

Commit

Permalink
Strengthened deathwatch tests and uncovered a bug wherein watching a …
Browse files Browse the repository at this point in the history
…dead actor results in a termination message from the wather (as opposed to the watched actor)
  • Loading branch information
Erik Allik committed Sep 26, 2013
1 parent ab3a820 commit 512260f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion spinoff/actor/ref.py
Expand Up @@ -162,7 +162,7 @@ def send(self, message, _sender=None):
cell.receive(message, _sender) # do NOT set self._cell--it will never be unset and will cause a memleak
return
if ('_watched', ANY) == message:
message[1].send(('terminated', self))
message[1].send(('terminated', self), _sender=self)
elif (message == ('terminated', ANY) or message == ('_unwatched', ANY) or message == ('_node_down', ANY) or
message == '_stop' or message == '_kill' or message == '__done'):
pass
Expand Down
13 changes: 7 additions & 6 deletions spinoff/tests/actor_test.py
Expand Up @@ -1018,15 +1018,16 @@ def pre_start(self):
self.watch(watchee)

def receive(self, message):
message_receieved.set(message)
message_receieved.set((self.sender, message))

node = DummyNode()
defer(node.stop)
message_receieved = AsyncResult()
watchee = node.spawn(Actor)
node.spawn(Watcher)
idle()
watchee.stop()
eq_(message_receieved.get(), ('terminated', watchee))
eq_(message_receieved.get(), (watchee, ('terminated', watchee)))


@deferred_cleanup
Expand All @@ -1039,13 +1040,13 @@ def pre_start(self):
self.watch(a)

def receive(self, message):
message_receieved.set(message)
message_receieved.set((self.sender, message))

node = DummyNode()
defer(node.stop)
watchee, message_receieved = AsyncResult(), AsyncResult()
node.spawn(Watcher)
eq_(message_receieved.get(), ('terminated', watchee.get()))
eq_(message_receieved.get(), (watchee.get(), ('terminated', watchee.get())))


@deferred_cleanup
Expand All @@ -1055,7 +1056,7 @@ def pre_start(self):
self.watch(watchee)

def receive(self, message):
message_receieved.set(message)
message_receieved.set((self.sender, message))

node = DummyNode()
defer(node.stop)
Expand All @@ -1064,7 +1065,7 @@ def receive(self, message):
watchee.stop()
idle()
node.spawn(Watcher)
eq_(message_receieved.get(), ('terminated', watchee))
eq_(message_receieved.get(), (watchee, ('terminated', watchee)))


@deferred_cleanup
Expand Down

0 comments on commit 512260f

Please sign in to comment.