celluloid/celluloid — pull request #231 by halorgium (2013-05-09 05:40:03+00:00)
Title: Tasks which are terminated on actor termination do so silently

```ruby
class MyActor
include Celluloid

def name
logger.info "You'll see this"
"Foo"
end

def terminate_and_ask_name(other_actor)
terminate
other_actor.name
logger.info "You'll never get here"
end
end

a = MyActor.new
b = MyActor.new
a.terminate_and_ask_name b
```

The situation is this internally:

1. Terminate sets `@running` to `false`, which causes the next tick of `#receive` to terminate the actor, and therefore not listen to further responses from a `SyncCall`.
2. The `SyncCall` (`#name`) suspends the `Task` running `#terminate_and_ask_name`, which triggers the next tick of `#receive`.
3. The `SyncCall` is thus correctly dispatched to `other_actor`, but the caller never bothers to listen for the response, and so the `Task` running `#terminate_and_ask_name` is terminated.
4. Terminating the `Task` is silent: no exceptions in the calling actor, no logging and the `SyncCall` does not fail early with an exception like "You're not gonna listen to the answer so don't ask the question".

Note also that a similar thing could happen if another task terminates the calling actor while it's waiting for a response to the SyncCall.

I've discussed this a bunch with @halorgium and he thinks adding logging of unfinished `Task`s on actor termination is the appropriate way to deal with this since any more involved reasoning about how to handle such issues is too difficult to get right.