Call function using a greenlet and return the result as a Deferred

def deferToGreenlet(*args, **kwargs):
    """Call function using a greenlet and return the result as a Deferred"""
    from twisted.internet import reactor
    assert reactor.greenlet == getcurrent(), "must invoke this in the reactor greenlet"
    return deferToGreenletPool(reactor, reactor.getGreenletPool(), *args, **kwargs)