snakeMQ
stable
  • 1. Changelog
  • 2. Tutorial
  • 3. API
    • 3.1. Link
      • 3.1.1. Callbacks
    • 3.2. Packeter
    • 3.3. Messaging
    • 3.4. Miscellaneous
snakeMQ
  • Docs »
  • 3. API »
  • 3.1. Link
  • Edit on GitHub

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() and on_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_send before 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_send to 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.

3.1.1. Callbacks¶

Link.on_recv = None¶

func(conn_id, data)

Link.on_ready_to_send = None¶

func(conn_id, last_send_size), last send was successful

Link.on_loop_pass = None¶

func(), called after poll is processed

Next Previous

© Copyright 2015, David Siroky Revision 10be2879.

Built with Sphinx using a theme provided by Read the Docs.
© Copyright 2015, David Siroky.
www.snakemq.net