3.1. Link¶
-
class
snakemq.link.SSLConfig(keyfile=None, certfile=None, cert_reqs=0, ssl_version=2, ca_certs=None)¶ Container for SSL configuration.
-
__init__(keyfile=None, certfile=None, cert_reqs=0, ssl_version=2, ca_certs=None)¶ See: ssl.wrap_socket
-
-
class
snakemq.link.LinkSocket(sock=None, ssl_config=None, remote_peer=None)¶ -
getpeercert(binary_form=False)¶ See: python documentation - ssl.SSLSocket.getpeercert() Returns: peer’s SSL certificate if available or None
-
-
class
snakemq.link.Link¶ Just a bare wire stream communication. Keeper of opened (TCP) connections. Not thread-safe but you can synchronize with the loop using
wakeup_poll()andon_loop_pass.-
add_connector(address, reconnect_interval=None, ssl_config=None)¶ This will not create an immediate connection. It just adds a connector to the pool.
Parameters: - address – remote address
- reconnect_interval – reconnect interval in seconds
Returns: connector address (use it for deletion)
-
add_listener(address, ssl_config=None)¶ Adds listener to the pool. This method is not blocking. Run only once.
Returns: listener address (use it for deletion)
-
cleanup()¶ Close all sockets and remove all connectors and listeners.
-
del_connector(address)¶ Delete connector.
-
del_listener(address)¶ Delete listener.
-
loop(poll_timeout=0.2, count=None, runtime=None)¶ Start the communication loop.
Parameters: - poll_timeout – in seconds, should be less then the minimal reconnect time
- count – count of poll events (not timeouts) or None
- runtime – max time of running loop in seconds (also depends on the poll timeout) or None
-
send(conn_id, data)¶ After calling send wait for
on_ready_to_sendbefore sending next data.This operation is non-blocking, data might be lost if you close connection before proper delivery. Always wait for
on_ready_to_sendto have confirmation about successful send and information about amount of sent data.Do not feed this method with large bulks of data in MS Windows. It sometimes blocks for a little time even in non-blocking mode.
Optimal data size is 16k-64k.
-
stop()¶ Interrupt the loop. It doesn’t perform a cleanup.
-
wakeup_poll()¶ Thread-safe.
-