Util module

Utility module

Some useful gevent functions.

gevent_tools.util.connect_and_retry(address, source_address=None, max_retries=None, delay=1.0, max_delay=3600)[source]

Connect and retry based on Twisted’s ReconnectingClientFactory

Wraps gevent.socket.create_connection with a loop for max_retries (if given) using delay and max_delay (and several magic constants) to do a linear backoff with builtin jitter to avoid stampede.

gevent_tools.util.line_protocol(socket_or_file, strip=True)[source]

Generator for looping line-based protocol

Takes a socket or file-from-socket and yields on every line. Disconnecting or connection errors will end the loop.

This Page