def safe_joinall(greenlets, timeout=None, raise_error=False):
greenlets = list(greenlets)<EOL>try:<EOL><INDENT>gevent.joinall(greenlets, timeout=timeout, raise_error=raise_error)<EOL><DEDENT>except gevent.GreenletExit:<EOL><INDENT>[greenlet.kill() for greenlet in greenlets if not greenlet.ready()]<EOL>raise<EOL><DEDENT>return greenlets<EOL>
Wrapper for gevent.joinall if the greenlet that waits for the joins is killed, it kills all the greenlets it
joins for.