This release is a pre-release and may not be stable for production use.
Israeli Queue
A fast Python (Cython) implementation of an Israeli Queue.
Table of Contents
- Overview
- What is an Israeli Queue?
- Installation
- Classes
- Documentation
- Complexity
- Synchronous Example
- Asynchronous Example
- License
Overview
This project implements a queue system where each item is associated with a "group." The queue processes items in groups, ensuring that items belonging to the same group are dequeued together. This implementation provides both a synchronous version (IsraeliQueue) and an asynchronous version (AsyncIsraeliQueue) using asyncio.
What is an Israeli Queue?
An Israeli Queue is a type of a priority queue where tasks are grouped together in the same priority. Adding new tasks to the queue will cause them to skip the line and group together. The tasks will then be taken out in-order, group by group.
Why is this useful?
IsraeliQueues enjoy many benefits from processing grouped tasks in batches. For example, imagine a bot or an API that requires logging in to a remote repository in order to bring files:
def login(repo_name: str):
return Session("repo_name") # Expensive operation
def download_file(session: Session, filename: str):
return Session.download(filename)
def logout(session: Session):
session.logout
Now, we have a thread or an asyncio task that adds files to download to the queue:
from israeliqueue import IsraeliQueue
queue = IsraeliQueue()
queue.put("cpython", "build.bat")
queue.put("black", "pyproject.toml")
queue.put("black", "bar") # Same repo as the second item
queue.put("cpython", "index.html") # Same repository as the first item
An ordinary queue will cause our bot to login and logout four times, processing each item individually. The IsraeliQueue groups the repositories together, saving setup costs and allowing to download them all in the same request:
while True:
group, items = queue.get_group()
session = login(group)
for item in items:
download_file(session, item)
logout(session)
If the downloading process accepts multiple files at once, it's even more efficient:
session.download_files(*items)
Other uses may include batching together AWS queries, batching numpy calculations, and plenty more!
Installation
To install the package, simply pip install cisraeliqueue.
You can use the classes in your project as follows:
from israeliqueue import IsraeliQueue, AsyncIsraeliQueue
Classes
IsraeliQueue
This is the synchronous implementation of the Israeli Queue. It provides group-based task processing and supports both blocking and non-blocking queue operations. The class is thread-safe and can be used in multithreaded environments.
AsyncIsraeliQueue
This is the asynchronous version of the Israeli Queue, built using Python's asyncio framework. It provides non-blocking, asynchronous methods for queue operations and is suitable for applications requiring high concurrency and asynchronous task management.
Documentation
Full documentation exists on our RTD page.
Complexity
- put / put_nowait: O(1) - Insertion at the end of the queue.
- get / get_nowait: O(1) - Dequeueing from the front of the queue.
- get_group / get_group_nowait: O(group) - Dequeueing all items from the same group.
- task_done: O(1) - Simple bookkeeping to track completed tasks.
- join: O(1) - Blocks until all tasks are done
Synchronous Example
from israeliqueue import IsraeliQueue
# Initialize the queue
queue = IsraeliQueue(maxsize=10)
# Add items to the queue
queue.put('group1', 'task1')
queue.put('group1', 'task2')
queue.put('group2', 'task3')
# Get items from the queue
group, task = queue.get()
print(f"Processing {task} from {group}")
# Get all items from the same group
group, tasks = queue.get_group()
print(f"Processing all tasks from {group}: {tasks}")
# Mark the task as done
queue.task_done()
# Wait for all tasks to complete
queue.join()
Asynchronous Example
import asyncio
from israeliqueue import AsyncIsraeliQueue
async def main():
# Initialize the queue
queue = AsyncIsraeliQueue(maxsize=10)
# Add items to the queue
await queue.put('group1', 'task1')
await queue.put('group1', 'task2')
await queue.put('group2', 'task3')
# Get items from the queue
group, task = await queue.get()
print(f"Processing {task} from {group}")
# Get all items from the same group
group, tasks = await queue.get_group()
print(f"Processing all tasks from {group}: {tasks}")
# Mark the task as done
queue.task_done()
# Wait for all tasks to complete
await queue.join()
# Run the async example
asyncio.run(main())
License
This project is licensed under the MIT License.
Release files for cisraeliqueue 0.0.1a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 4.6 MB
Release files / cisraeliqueue-0.0.1a2-cp313-cp313-win_amd64.whl
| Download URL | cisraeliqueue-0.0.1a2-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 80.1 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9efc3dd4ddb2e3f57a60f282bbef4513d25eaf0a7c063f40765e02a54cc923eb
|
|
BLAKE2b-256 checksum How to use checksums |
837a99afd1b92c40f5b84487b4d8d926930e1a7acec193060735d5a5ac3d4a97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp313-cp313-win32.whl
| Download URL | cisraeliqueue-0.0.1a2-cp313-cp313-win32.whl |
|---|---|
| Size | 70.7 kB |
| Tags | CPython 3.13 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
0cc11fd86d8f2d92cea0ac3c8371d6442bde8f3b3f02209d764a02d59ee38410
|
|
BLAKE2b-256 checksum How to use checksums |
41a92d218de1b86c4dddaf60506c97d155d0495fd14f8b3e7dce2de2c9eb78f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp313-cp313-musllinux_1_2_x86_64.whl
| Download URL | cisraeliqueue-0.0.1a2-cp313-cp313-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 513.0 kB |
| Tags | CPython 3.13 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
d0b0107a05b49692360214cf4ce7360cf3d3912b3ba1a826fab801424a18e63c
|
|
BLAKE2b-256 checksum How to use checksums |
be6914d1ddb709ec8dc0b2ca1203828454fa3f569c167ef5e5a5f7930661b02f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp313-cp313-musllinux_1_2_i686.whl
| Download URL | cisraeliqueue-0.0.1a2-cp313-cp313-musllinux_1_2_i686.whl |
|---|---|
| Size | 491.9 kB |
| Tags | CPython 3.13 Linux musl 1.2+ x86-32 |
|
SHA-256 checksum How to use checksums |
7555e5e6639e9bae5cdabb28a1bfca845f774d72e540780df1290b07f3f28da9
|
|
BLAKE2b-256 checksum How to use checksums |
4f75a8b7558f8d7432f8104d18d4fa8e7594bca76e156226d5e377dc30465133
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | cisraeliqueue-0.0.1a2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 504.9 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
9e6aab06c79058347c0482f723ea6ac7a45d6c8ec91a6c525720b209cf4d9e0f
|
|
BLAKE2b-256 checksum How to use checksums |
44c6896912db41812dbc89144008f6a911a9d3704f65c20e80db9e8a8f022e59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | cisraeliqueue-0.0.1a2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 479.5 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
f359720be3460193dcc93067bb396c10b0c6e0baf186024399bbb775d7eec8d4
|
|
BLAKE2b-256 checksum How to use checksums |
7ce28d93a4f553777a9a6f659b1e485cc37ae5d0a0734641e0e682383f5747d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | cisraeliqueue-0.0.1a2-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 89.8 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3fa37b0fccc08ffbd6fc9198123c6f7825b9004a158f358cd328df7804919238
|
|
BLAKE2b-256 checksum How to use checksums |
ddff9bff0f3ddb3a410b1153a660a30f6aa503d76327f493159823bc95dadaa5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | cisraeliqueue-0.0.1a2-cp313-cp313-macosx_10_13_x86_64.whl |
|---|---|
| Size | 93.7 kB |
| Tags | CPython 3.13 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
1c50bd5c8509231cc590dc795ae55fbcf5244e3b9263e62f97114dda5ee1f438
|
|
BLAKE2b-256 checksum How to use checksums |
19b179f0b493e65b8d7e362a9f8131dea1636ee20c7ce3fae01f82decb2b2881
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp312-cp312-win_amd64.whl
| Download URL | cisraeliqueue-0.0.1a2-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 80.4 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c2689ed47e94efb9c302ce85b9d450a6b926d9785f277ab93e8c536ca8ea83ea
|
|
BLAKE2b-256 checksum How to use checksums |
8d27fa11d29b2ba4c1e21c8d0498c51ac9d299541fbc7a20f1cb342cb997a4f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp312-cp312-win32.whl
| Download URL | cisraeliqueue-0.0.1a2-cp312-cp312-win32.whl |
|---|---|
| Size | 70.7 kB |
| Tags | CPython 3.12 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
88e99f8ba3d502a164a97071a123821841235991b118c1ee3bd065ae78ae972c
|
|
BLAKE2b-256 checksum How to use checksums |
94104b35622de0a58c95f123a3f655ace94a1403d3acd1d5e278bd18331e6490
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp312-cp312-musllinux_1_2_x86_64.whl
| Download URL | cisraeliqueue-0.0.1a2-cp312-cp312-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 507.8 kB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
df781fee212090bf6c3e69a540a985ac4f1eff12cd3ebcc1363cedc59aacd043
|
|
BLAKE2b-256 checksum How to use checksums |
2992dff8c4d951ef02ea0a66f9b06128d2213958929ed33af2378e49a8e9bdd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp312-cp312-musllinux_1_2_i686.whl
| Download URL | cisraeliqueue-0.0.1a2-cp312-cp312-musllinux_1_2_i686.whl |
|---|---|
| Size | 491.3 kB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-32 |
|
SHA-256 checksum How to use checksums |
8831e83969cd1ac7daa1ca44e788cb4925ff9e091ba2d56b847c0c75c7bf98ee
|
|
BLAKE2b-256 checksum How to use checksums |
ffe61bf618951af755d1bed88bbf6e929d0307bfe336971c32a7fd01f37a9df7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | cisraeliqueue-0.0.1a2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 506.4 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
e6ea8efea87ae28a8281a689bbf78e353750208cb18840ef3512f825a3baf933
|
|
BLAKE2b-256 checksum How to use checksums |
2ae96b7ddc5cd264445363baf08426866803951abf8a8629caeda4d5ad35bbbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | cisraeliqueue-0.0.1a2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 478.2 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
30bdc2e4faa1b697d6c699fc7a87d971fa80f60a95cd6c12d60a3b19221d922b
|
|
BLAKE2b-256 checksum How to use checksums |
c99af8c66a9d1ddd739ddcacc109c7393ec8656642e4f249a79433824e32fe79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | cisraeliqueue-0.0.1a2-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 90.5 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9cb3ceb43e54504b521f87a58ee39cd8e15cb10ef1d9f1c84391f71aa25f3963
|
|
BLAKE2b-256 checksum How to use checksums |
dba73e1dc4a9d66e430b61a294f29e52cc4f7b03b423f143223bcf1bb963848d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / cisraeliqueue-0.0.1a2-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | cisraeliqueue-0.0.1a2-cp312-cp312-macosx_10_13_x86_64.whl |
|---|---|
| Size | 95.0 kB |
| Tags | CPython 3.12 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
0d0f8260d88f3abf3fb447f74038d208990541566e038c60998afb7cae628051
|
|
BLAKE2b-256 checksum How to use checksums |
df82988f7164db9e44cc6a3d0530042a8a22b36b2659bcde3c383f9bec92e198
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|