WebFilings/furious — pull request #120 by rosshendrickson-wf (2014-03-06 07:10:56+00:00)
Title: Completion

Adds the on_success and on_failure properties to both the Context and the Async and allows them to be encoded and decoded to JSON. Allows Aync, Context, or references to be assigned to the on_success or on_failure properties.

Adds using Kepler to keep track of a completion graph while allowing multi level completion.

```
def foo():
print 'foo'

def bar():
print 'bar'

def foo_bar():
print 'foo_bar'

context_a = Context()
async_a = Async(target=foo)
context_a.on_success = foo_bar
context_a.add(async_a)

context_b = Context()
context_b.on_success = context_a
async_b = Async(target=bar)
context_b.add(async_b)
context_b.start()

Should print
bar
foo
foo_bar
```

I did my best to write tests to ensure this works and to make sure I wasn't adding too much to the existing furious code itself. processor.py only had a single line change because I added the ability to actually store a reference for the _process_results part (that is how we know to make the call into kepler to mark complete). The only shaky part of this is how get_current_context() and get_current_async() will work as that is how I am determining when to create or add to the completion graph.

This is rougher than I'd hoped but It should be in a place to start having some comments. I thought about using a mixin with Async and Context that added the on_success and on_failure properties but ran out of time (to keep things DRYer).