Skip to content

Fix crontab dependency naming conflict#326

Open
millsks wants to merge 1 commit intorq:masterfrom
millsks:master
Open

Fix crontab dependency naming conflict#326
millsks wants to merge 1 commit intorq:masterfrom
millsks:master

Conversation

@millsks
Copy link

@millsks millsks commented Dec 1, 2025

This pull request updates the scheduler's cron handling by switching from the crontab library to pychronotab, modernizes the CI workflow, and improves test compatibility with newer RQ versions.

When both django-celery-beat and rq-scheduler are installed they are using two different crontab libraries, but both have the same crontab module name. This is causing errors and prevents the dual-queue configuration from functioning.

  • pychronotab is a drop-in replacement with full croniter API compatibility and active maintenance.
  • Eliminates namespace conflicts when using multiple schedulers on the same system (e.g., django-celery-beat with python-crontab and rq-scheduler).
  • pychronotab keeps crontab, croniter, and other package names at a lower level to avoid top-level import conflicts.
  • All 75 tests passing with the new implementation.

Cron Parsing and Scheduling Updates:

  • Replaced the crontab library with pychronotab for cron expression parsing in rq_scheduler/utils.py, updating logic to use croniter and handle timezone-aware datetimes. [1] [2]
  • Updated tests in tests/test_scheduler.py to use UTC consistently for cron scheduling and adjusted cron string format to 5 fields for compatibility. [1] [2]

Dependency and Workflow Modernization:

  • Updated dependencies in setup.py to require pychronotab instead of crontab.
  • Modernized the GitHub Actions workflow to use Ubuntu 24.04, newer Python and redis-py versions, and streamlined installation commands. [1] [2]

Test Suite Compatibility Improvements:

  • Adjusted callback tests in tests/test_callbacks.py to be compatible with internal changes in newer RQ versions by relaxing internal state assertions. [1] [2]
  • Added missing imports and a tearDown method to tests/test_scheduler.py for improved test reliability and mocking. [1] [2]* Fix incorrect crontab dependency.

* Fix incorrect crontab dependency.

When both Celery and rq-scheduler are installed they are using two different crontab libraries, but both have the same crontab module name. This is causing errors and prevents the dual-queue configuration from functioning.

Root Cause
There are two different packages on PyPI with similar names:

crontab (https://pypi.org/project/crontab/) - A different cron scheduling library
python-crontab (https://pypi.org/project/python-crontab/) - The correct package for reading/writing system crontabs

* Update workflow matrix for Python and Redis versions

* Update Ubuntu version in workflow configuration

* Change installation command to use pip install

* Refactor crontab handling to use croniter for scheduling and update dependencies

* Update crontab dependency to pychronotab

* `pychronotab` is a drop-in replacement with full croniter API compatibility and active maintenance.
* Eliminates namespace conflicts when using multiple schedulers on the same system (e.g., django-celery-beat with `python-crontab` and rq-scheduler).
* `pychronotab` keeps `crontab`, `croniter`, and other package names at a lower level to avoid top-level import conflicts.
* All 75 tests passing with the new implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant