dreid/yunomi — pull request #15 by hawkowl (2013-08-31 18:05:35+00:00)
Title: Add Twisted Deferred support

This patch adds Deferred support to `time_calls` and `hist_calls` by a wrapper function. Instead of updating the timer or updating with the result upon calling it (which, will be a Deferred, not an actual result), it tacks on a callback which does the updating instead. If the function does not return a Deferred, it calls the callback synchronously and returns the result as expected.

I tested it in a virtualenv which had no Twisted and it worked, although I am not absolutely sure, but Travis should be able to tell us that.

All tests pass here - I'm not 100% sure how I can write tests that will work if Twisted isn't there, since it uses Trial... so I'm not sure if I just need to write some additional tests that assume Twisted is there?