[Twisted-Python] PB waitingForAnswers KeyError

Jp Calderone exarkun at divmod.com
Sat Jul 23 02:28:01 EDT 2005

On Sat, 23 Jul 2005 01:56:29 -0400, William Waites <ww at groovy.net> wrote:
>or more correctly,
>def invert(f):
>    def _i(*av, **kw)
>        e = Event()
>        result = []
>        def _s(res):
>            result.append(res)
>            e.set()
>        def _f():
>            d = maybeDeferred(f, *av, **kw)
>            d.addBoth(_s)
>        reactor.callFromThread(_f)
>        e.wait()
>        res = result[0]
>        if isinstance(res, Exception):
>            raise res
>        return res
>    return _i
>should this function exist somewhere in twisted?

One might take the position that if you are not experience enough to write it yourself, you are not experience enough to write a multithreaded program.

FWIW, this function has actually been written a handful of times, and at least a couple copies of it are in the list archives.  There's also an open issue in the bug tracker related to it.  I believe it is stalled on the submission of a reasonable set of unit tests.


More information about the Twisted-Python mailing list