If twisted is available, make `emit' return a DeferredList

    This has been successfully tested with Twisted 14.0 and later.

def install_twisted():
    """
    If twisted is available, make `emit' return a DeferredList

    This has been successfully tested with Twisted 14.0 and later.
    """
    global emit, _call_partial
    try:
        from twisted.internet import defer
        emit = _emit_twisted
        _call_partial = defer.maybeDeferred
        return True
    except ImportError:
        _call_partial = lambda fn, *a, **kw: fn(*a, **kw)
        return False