Package: lingerclient
Lingerclient-- Blocking and non-blocking (asynchronous) clients for LingerThis package provides Python clients for interacting with aLingerserver, which is a message queue and pubsub service with a REST HTTP API.The linger clients are implemented in Python 3 usingTornadoHTTP clients.InstallInstall thelingerclientpackage with the following pip command:pip install lingerclientThis will also ensure that the dependency packagetornadois installed.Example codeBlocking client example:import lingerclient

lc = lingerclient.BlockingLingerClient()
r = lc.post('test-channel', {'msg': 'My first message'})
print(r)
print(lc.channels())
m = lc.get('test-channel')
lc.delete(m['id'])Thestreammethod can be used for iterating over a stream from a channel:for m in lc.stream('test-channel'):
    print(m['body'])
    lc.delete(m['id'])Async client example:import lingerclient
from tornado import ioloop, gen@gen.coroutine
def run_test():
    lc = lingerclient.AsyncLingerClient()
    r = yield lc.post('test-channel', {'msg': 'My first message'})
    print(r)
    r = yield lc.channels()
    print(r)
    m = yield lc.get('test-channel')
    yield lc.delete(m['id'])


ioloop.IOLoop.current().run_sync(run_test)Main client methodschannels()List active channelspost(channel, body, **kwargs)Post a message in the channel. Accepts keyword arguments for the query parameters: priority, timeout, deliver and linger.get(channel, nowait=False)Get a message from the channel. Returns the a dict with the message id, body, channel, etc. If no message is available, None is returned. Set argumentnowaitto True to prevent long-polling.stream(channel, max_retries=0)Get a stream (iterator) for channel. Argument max_retries can limit the number of failed reconnection attempts. Default is max_retries=0, which means no limit.drain(channel)Drain the channel for messages (ie, delete all messages in the channel).channel_stats(channel)Get channel statssubscriptions(channel)List topics the channel is subscribed tosubscribe(channel, topic, **kwargs)Subscribe channel to topic. Accepts keyword arguments for the query parameters: priority, timeout, deliver and lingerunsubscribe(channel, topic)Unsubscribe channel from topictopics()List all topicspublish(topic, body)Publish message on topicsubscribers(topic)List channels subscribed to topicdelete(msg_id)Delete messagestats()Get server statsOther client methods__init__(linger_url=None, encode=json_encode, decode=json_decode, content_type='application/json', io_loop=None, **request_args)The method signature is the same forAsyncLingerClientandBlockingLingerClient, as BlockingLingerClient is a wrapper for AsyncLingerClient, where each HTTP request to Linger is run in an IOLoop.All parameters are optional.Thelinger_urlargument is the base url for the Linger server. Default ishttp://127.0.0.1:8989/.Theencodeanddecodearguments are for supplying custom message encoding and decoding functions. Default is JSON encoding/decoding.Thecontent_typeargument should be set to the appropriate mime-type of the output of the encoding function. Default isapplication/json.Theio_loopis passed to the AsyncHTTPClient, used for connecting.Keyword arguments inrequest_argsare applied when making requests to Linger. By default the request argumentuse_gzipis True. Accessing a local Linger server, it may be relevant to setuse_gzipto False.The request arguments may includeauth_usernameandauth_passwordfor basic authentication. Seetornado.httpclient.HTTPRequestfor other possible arguments.close()Closes the Linger client, freeing any resources used.closed(property)Boolean indicating if the Linger client is closed.SupportSupport for the software can be provided on a commercial basis, please seewww.nephics.comfor contact information.LicenseThe code and documentation is licensed under the Apache License v2.0, see more in the LICENSE file.