Skip to main content

Minimal Redis job runner

Project description

minique /miniːk/

A minimal Redis 4.0+ job queue for Python 3.7 and above.

Requirements

  • Python 3.7+
  • Redis 4.0+

Usage

  • Have a Redis 4.0+ server running.

Client

from redis import StrictRedis
from minique.api import enqueue, get_job

# Get a Redis connection, somehow.
redis = StrictRedis.from_url('redis://localhost:6379/4')

job = enqueue(
    redis=redis,
    queue_name='work',
    callable='my_jobs.calcumacalate',  # Dotted path to your callable.
    kwargs={'a': 5, 'b': 5},  # Only kwargs supported.
    # You can also set a `job_id` yourself (but it must be unique)
)

job_id = job.id  # Save the job ID somewhere, maybe?

while not job.has_finished:
    pass  # Twiddle thumbs...

print(job.result)  # Okay!

# Get the same job later (though not later than 7 days (by default)):
job = get_job(redis, job_id)

Worker(s)

  • Ensure your workers are able to import the functions you wish to run.
  • Set the callables the worker will allow with --allow-callable.
    • Alternately, you may wish to subclass minique.work.job_runner.JobRunner to specify an entirely different lookup mechanism.
$ minique -u redis://localhost:6379/4 -q work -q anotherqueue -q thirdqueue --allow-callable 'my_jobs.*'

Sentry Support

Minique automatically integrates with the Sentry exception tracking service.

You can use the [sentry] installation extra to install sentry-sdk along with Minique, or you can do it manually.

Simply set the SENTRY_DSN environment variable; if all goes well, you should see a "Sentry configured with a valid DSN" message at CLI boot.

The other environment-configurable options also work as you would expect.

Exceptions occurring during job execution will be sent to Sentry and annotated with minique context describing the job ID and queue name.

Development

# install `minique` in editable mode with development dependencies
pip install -e .[sentry,test] pre-commit mypy==1.0.0 types-redis && pre-commit install

# run lints
pre-commit run --all-files

# run type checks
mypy --strict --install-types --show-error-codes minique

# run tests against the specified Redis database
REDIS_URL=redis://localhost:6379/0 pytest .

Release

# decide on a new version number and set it
vim minique/__init__.py
__version__ = "0.9.0"

npx auto-changelog --commit-limit=0 -v 0.9.0

# undo changes changelog generation did to the older entries

git add -u
git commit -m "Become 0.9.0"
git tag -m "v0.9.0" -a v0.9.0

git push --follow-tags

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

minique-0.9.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

minique-0.9.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file minique-0.9.1.tar.gz.

File metadata

  • Download URL: minique-0.9.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for minique-0.9.1.tar.gz
Algorithm Hash digest
SHA256 4bea073ba30361ce6f467dc33842974bb180ffbaf2b5689242ba0769a4c02eee
MD5 6965284b9a4f9454476ff8cbd0554db8
BLAKE2b-256 4b428700a51777628dda99cf5b24995d4f686a47a3b2d0fcd898da3200c6e411

See more details on using hashes here.

File details

Details for the file minique-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: minique-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for minique-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 45481332f3e24a47073223c0aa5a29c461203de4f4bb37b40c854cb8c13b6f5f
MD5 10e4c390eff059a6488abf919dcffbfc
BLAKE2b-256 c8326deb49e15c4673434956c1a269994ede9b969e44a1d75c013764fdc634f3

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