calendar-queue
A pure-python calendar queue and library for scheduling events with asyncio.
Many other libraries allow for event/job scheduling but either they are not asynchronous or they are just fire-and-forget.
calendar-queue has two purposes:
- providing the primitives for creating your own scheduler by exporting a
CalendarQueueclass in which events can be awaited - providing a higher level abstraction
Calendarclass that simplifies the usage ofCalendarQueue.
Depending on your needs, you can use one of the two to develop your own event manager/scheduler.
The idea is: we take care of emitting events at the right time, you write the logic for acting accordingly.
Install
pip install calendar-queue
Usage
Quickstart
A minimal, practical example showing how Calendar can schedule and emit events: schedule three reminders a few seconds apart and consume them as they fire.
import asyncio
from datetime import datetime, timedelta
from calendar_queue import Calendar
calendar = Calendar()
async def producer():
for i in range(1, 4):
when = datetime.now() + timedelta(seconds=i * 2)
calendar.schedule(f"Reminder {i}", when=when)
print(f"scheduled Reminder {i} for {when.isoformat()}")
await asyncio.sleep(0.1)
async def consumer():
async for ts, event in calendar:
print(f"{datetime.fromtimestamp(ts).isoformat()}: {event}")
# stop after the last event
if event == "Reminder 3":
calendar.stop()
async def main():
await asyncio.gather(producer(), consumer())
if __name__ == "__main__":
asyncio.run(main())
For more examples and the API reference, see the documentation in the docs folder:
- Tutorials: docs/tutorials
- API reference: docs/api-reference
Development
This library is developed using Python 3.11 and pdm as dependency manager.
Testing is done via github actions and it's done on python versions 3.10, 3.11, 3.12, 3.13, 3.14, 3.14t and on latest ubuntu, macos, windows OSes.
For local development you'll need to have pdm installed, then you can:
- run
pdm installto create the virtual environment and install the dependencies - run
pdm venv activateto activate the virtual environment - run the tests using
pytest - run the linter
pylint src
Contributing
Contributions are welcome! Especially for new tests and for improving documentation and examples.
License
The code in this project is released under the MIT License.
Metadata
Release files for calendar-queue 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| calendar_queue-0.2.2.tar.gz | 11.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| calendar_queue-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.2 kB
Release files / calendar_queue-0.2.2.tar.gz
| Download URL | calendar_queue-0.2.2.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cab0e745ac55fb3bfc49500773c213efc28ce6aa238e42f88434fbda628b8ea0
|
|
BLAKE2b-256 checksum How to use checksums |
266631922635c03279d31f4c5d37c59e2f7dc9d45aed2325fe1a332735ad4471
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.26.7 CPython/3.14.4 Linux/6.17.0-1010-azure
|
Release files / calendar_queue-0.2.2-py3-none-any.whl
| Download URL | calendar_queue-0.2.2-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a57574475a9eb65f2e1b42339afca6892e6320e69940cb92d9cbae13f2c1efa2
|
|
BLAKE2b-256 checksum How to use checksums |
435e5dfe7950b038ef1cce5270d5ae43e3c3d9266076540d439b37647f0692a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.26.7 CPython/3.14.4 Linux/6.17.0-1010-azure
|