SIPp / pysipp

SIPp for Humans - launch multiple agents with Python
GNU General Public License v2.0
179 stars 55 forks source link

launch multiple scenarios with a context manager #22

Open goodboy opened 8 years ago

goodboy commented 8 years ago

Ended up using something similar for some FreeSWITCH cluster testing and figured it might as well be part of the pysipp API:

from contextlib import contextmanager

@contextmanager
def multicall(dialers):
    finalizers = []
    for for dialer in dialers:
        finalizers.append(dialer(block=False))

    yield dialers

    for finalize in finalizers:
        finalize()

It basically wraps the async usage from the README.