Skip to main content

Tarantool Queue python bindings for asyncio

Project description

Bindings require tarantool version 1.6 and aiotarantool connector:

$ pip install aiotarantool_queue

Try it example:

import aiotarantool_queue
import random

@asyncio.coroutine
def put_job(queue):
    for tube_name in ("tube1", "tube2", "tube3"):
        tube = queue.tube(tube_name)
        task = yield from tube.put({"task_data": random.random()})

@asyncio.coroutine
def take_job(tube):
    while True:
        task = yield from tube.take(5)
        if not task:
            break

        print(task.data)
        yield from task.ack()

loop = asyncio.get_event_loop()

queue = aiotarantool_queue.queue("127.0.0.1", 3301)
put_tasks = [asyncio.async(put_job(queue))
             for _ in range(20)]

take_tasks = [asyncio.async(take_job(queue.tube(tube_name)))
              for tube_name in ("tube1", "tube2", "tube3")]

loop.run_until_complete(asyncio.wait(put_tasks + take_tasks))
loop.run_until_complete(queue.close())
loop.close()

This code makes it easy to develop your application to work with queue

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiotarantool_queue-0.0.1.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file aiotarantool_queue-0.0.1.tar.gz.

File metadata

File hashes

Hashes for aiotarantool_queue-0.0.1.tar.gz
Algorithm Hash digest
SHA256 01fe264e68cfb567733fc95b7a85e151a7165fa5cbcf1e437a39be9c794b1266
MD5 71fac90dbd496c5759a0ffe019649f72
BLAKE2b-256 7abc8aad6ab7744d4349ddb1912bd509738c961426b4a5f296f40e4552c21333

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page