Skip to main content

atq

atq is a pure-Python asynchronous task queue built to work with asyncio. It is designed to run costly functions outside main event loop using distributed workers.

atq requires Python 3.5+ and is distributed under BSD license.

Usage

First, you should start workers on the servers you plan to use for task execution

atqserver --host <hostname> --port <port-number> --worker <num-workers>

where

  • <hostname> is a hostname of the server

  • <port-number> is a port that server will listen on

  • <num-workers> is a number of worker processes

Please note that code of tasks should be accessible by atq, so it’s advised to run atq server from your project root directory in more complex situations.

Then you will need to create a client using hostnames and ports of initialized servers:

import atq

q = atq.Q([
     ("localhost", 12345),
 ])

Finally you can use atq in your code:

import atq
import asyncio
import requests
from collections import ChainMap
from collections import Counter

URLS = [
    ...
]

q = atq.Q([
    ("localhost", 12345),
])

def top_words(url, n):
    """Returns top n words from text specified by url."""
    text = requests.get(url).text.split()
    return {url: Counter(text).most_common(n)}

async def get_top_words(urls, n):
    """Returns top n words in documents specified by URLs."""
    tops_in_url = await asyncio.gather(
        *[q.q(top_words, url, n) for url in urls])
    return ChainMap(*tops_in_url)

top = asyncio.get_event_loop().run_until_complete(get_top_words(URLS, 10))

You can find more examples in examples subdirectory.

Installation

pip3 install atq

Testing

python3 setup.py test

License

BSD

Metadata

Release files for atq 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for atq 0.0.2
File Interpreter ABI Platform Actions
atq-0.0.2-py3-none-any.whl Python 3 none any Details for atq-0.0.2-py3-none-any.whl

Release files / atq-0.0.2-py3-none-any.whl

Download URL atq-0.0.2-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95922b23b5f62d4f35568f033890e37d714f1e94eecd77c28c7fd4ba8bab8d85
BLAKE2b-256 checksum
How to use checksums
6301334c22ec318b5769066af1872efcc1b854fc4b626300a03ec43b1def61d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for atq 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page