No project description provided
Project description
queue-local-python-package
Usage:
Install:
pip install queue-local
- It's recommended to add
queue-local
to yourrequirements.txt
file if you're using it as part of your project dependencies.
Using the DatabaseQueue
Class:
from queue_local.database_queue import DatabaseQueue
q = DatabaseQueue() # you can also pass some parameters here, see the class definition for more info
# Push items into the queue
q.push({"item_description": "test 1", "action_id": 1, "parameters_json": "{'a': 1, 'b': 2}"})
q.push({"item_description": "test 2", "action_id": 2, "parameters_json": {'a': 1, 'b': 2}})
# Peek at the first item in the queue (without removing it)
result1 = q.peek() # "test 1" is still in the queue
# Get an item from the queue (and remove it) based on action_id
result2 = q.get(action_ids=(2, )) # Gets "test 2" (the first item with action_id=2)
# Get an item from the queue (and remove it)
result3 = q.get() # Gets "test 1"
q.close() # close the database connection
Inheriting from the Abstract OurQueue
Class:
from queue_local.our_queue import OurQueue
class YourCustomQueue(OurQueue):
def __init__(self):
pass
def push(self, item):
"""Push an item to the queue"""
pass
def get(self):
"""Get an item from the queue (and delete)"""
pass
def peek(self):
"""Peek at the head of the queue (without deleting)"""
pass
# Add any additional functions you need, such as is_empty()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
queue-local-0.0.32.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for queue_local-0.0.32-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cacac67cd9a615bb7f45ea7bd5e77c22946cd6b0049376948831068ad601f698 |
|
MD5 | 24d7c00bd5b12aabf079a8ac3cbee8cd |
|
BLAKE2b-256 | 1af0bb8dd75ab43faf5c617ff5c63ed3800cad3f574e7cd25b8ebb688b9860fb |