(*tasks)
Useful for cleaning up tasks in tests
Useful for cleaning up tasks in tests
Useful for cleaning up tasks in tests
async def cancel(*tasks):
    """Useful for cleaning up tasks in tests"""
    # pylint: disable=broad-except
    ex = None
    for task in tasks:
        if task is None:
            continue

        # Cancel all the tasks any pull out any exceptions
        if not task.cancelled():
            task.cancel()
        try:
            await task
            task.result()
        except asyncio.CancelledError:
            pass
        except Exception as e:
            # aioredis hides errors which occurred within a pipline
            # by wrapping them up in a PipelineError. So see if that is
            # the case here
            if (
                # An aioredis pipeline error
                isinstance(e, aioredis.PipelineError)
                # Where one of the errors that caused it was a CancelledError
                and len(e.args) > 1
                and asyncio.CancelledError in map(type, e.args[1])
            ):
                pass
            else:
                # If there was an exception, and this is the first
                # exception we've seen, then stash it away for later
                if ex is None:
                    ex = e

    # Now raise the first exception we saw, if any
    if ex:
        raise ex
async def cancel ( * tasks ) : # pylint: disable=broad-except ex = None for task in tasks : if task is None : continue # Cancel all the tasks any pull out any exceptions if not task . cancelled ( ) : task . cancel ( ) try : await task task . result ( ) except asyncio . CancelledError : pass except Exception as e : # aioredis hides errors which occurred within a pipline # by wrapping them up in a PipelineError. So see if that is # the case here if ( # An aioredis pipeline error isinstance ( e , aioredis . PipelineError ) # Where one of the errors that caused it was a CancelledError and len ( e . args ) > 1 and asyncio . CancelledError in map ( type , e . args [ 1 ] ) ) : pass else : # If there was an exception, and this is the first # exception we've seen, then stash it away for later if ex is None : ex = e # Now raise the first exception we saw, if any if ex : raise ex