Skip to content

Commit 359ee48

Browse files
committed
Release v0.7.0
2 parents e7cd5ef + 842fd58 commit 359ee48

9 files changed

Lines changed: 101 additions & 76 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 49 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,54 @@
44
name: Python package
55

66
on:
7-
push:
8-
branches: [ develop ]
9-
pull_request:
10-
branches: [ develop ]
7+
push:
8+
branches: [ develop ]
9+
pull_request:
10+
branches: [ develop ]
1111

1212
jobs:
13-
lint:
14-
name: Check code style
15-
runs-on: ubuntu-latest
16-
container: python:3-slim
17-
steps:
18-
- uses: actions/checkout@v2
19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
python -m pip install flake8 black
23-
- name: Blacken code
24-
run: black . --safe --quiet
25-
- name: Lint with flake8
26-
run: |
27-
# stop the build if there are Python syntax errors or undefined names
28-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
29-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
30-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
31-
test:
32-
name: Test (Python, Django)
33-
runs-on: ubuntu-latest
34-
needs: lint
35-
strategy:
36-
matrix:
37-
python-version: [ 3.8, 3.9, "3.10" ]
38-
django-version: [ "3.2", "4.0" ]
39-
env:
40-
PYTHON: ${{ matrix.python-version }}
41-
DJANGO: ${{ matrix.django-version }}
42-
steps:
43-
- uses: actions/checkout@v2
44-
- name: Set up Python ${{ matrix.python-version }}
45-
uses: actions/setup-python@v2
46-
with:
47-
python-version: ${{ matrix.python-version }}
48-
- name: Install dependencies
49-
run: |
50-
python -m pip install --upgrade pip
51-
python -m pip install --upgrade django~=${{ matrix.django-version }}
52-
if [ -f requirements/local.txt ]; then pip install -r requirements/local.txt; fi
53-
- name: Test with pytest and update coverage
54-
run: |
55-
coverage run -m pytest
56-
coverage xml
57-
- name: Upload coverage to Codecov
58-
uses: codecov/codecov-action@v1
59-
with:
60-
token: ${{ secrets.CODECOV_TOKEN }}
61-
files: coverage.xml
62-
flags: unittests
63-
env_vars: PYTHON, DJANGO
64-
fail_ci_if_error: true
65-
verbose: true
13+
lint:
14+
name: Check code style
15+
runs-on: ubuntu-latest
16+
container: python:3-slim
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
python -m pip install flake8 black
23+
- name: Blacken code
24+
run: black . --safe --quiet
25+
- name: Lint with flake8
26+
run: |
27+
# stop the build if there are Python syntax errors or undefined names
28+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
29+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
30+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
31+
32+
tests:
33+
name: Python ${{ matrix.python-version }}
34+
runs-on: ubuntu-20.04
35+
strategy:
36+
matrix:
37+
python-version:
38+
- '3.9'
39+
- '3.10'
40+
- '3.11'
41+
- '3.12'
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: actions/setup-python@v5
45+
with:
46+
python-version: ${{ matrix.python-version }}
47+
cache: 'pip'
48+
cache-dependency-path: 'requirements/*.txt'
49+
- name: Upgrade packaging tools
50+
run: python -m pip install --upgrade pip setuptools virtualenv wheel
51+
- name: Install dependencies
52+
run: python -m pip install --upgrade codecov tox
53+
- name: Run tox targets for ${{ matrix.python-version }}
54+
run: tox run -f py$(echo ${{ matrix.python-version }} | tr -d . | cut -f 1 -d '-')
55+
- name: Upload coverage
56+
run: |
57+
codecov -e TOXENV,DJANGO

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
- Jarek Glowacki <jarekwg@gmail.com>
22
- Stas Kaledin <staskaledin@gmail.com>
33
- John Cass <john.cass77@gmail.com>
4+
- JAEGYUN JUNG <twiecgoddessana1229@gmail.com>

django_apscheduler/jobstores.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def update_job(self, job: AppSchedulerJob):
248248
# Acquire lock for update
249249
with transaction.atomic():
250250
try:
251-
db_job = DjangoJob.objects.get(id=job.id)
251+
db_job = DjangoJob.objects.select_for_update().get(id=job.id)
252252

253253
db_job.next_run_time = get_django_internal_datetime(job.next_run_time)
254254
db_job.job_state = pickle.dumps(
@@ -262,10 +262,11 @@ def update_job(self, job: AppSchedulerJob):
262262

263263
@util.retry_on_db_operational_error
264264
def remove_job(self, job_id: str):
265-
try:
266-
DjangoJob.objects.get(id=job_id).delete()
267-
except DjangoJob.DoesNotExist:
268-
raise JobLookupError(job_id)
265+
with transaction.atomic():
266+
try:
267+
DjangoJob.objects.select_for_update().get(id=job_id).delete()
268+
except DjangoJob.DoesNotExist:
269+
raise JobLookupError(job_id)
269270

270271
@util.retry_on_db_operational_error
271272
def remove_all_jobs(self):

docs/changelog.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# Changelog
22

33
This changelog is used to track all major changes to django-apscheduler.
4+
5+
## v0.7.0(2024-09-24)
6+
7+
**Enhancements**
8+
- Drop support for Python 3.8 and Django 3.2.
9+
- Add support for Python 3.9 to 3.12, Django 4.2 to 5.1
10+
- Bump pytest to >7, remove pytest-pythonpath as it is no longer needed.
11+
- Add tox.ini file to run tests against all supported versions of Python and Django.
12+
- Update CI configuration to use tox.
13+
14+
**Fixes**
15+
16+
- Take a database lock before updating / deleting job store entries to prevent duplicate key violation errors (thanks
17+
@calledbert).
418

519
## v0.6.2 (2022-03-06)
620

pytest.ini

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
[pytest]
2+
pythonpath = .
23
python_files = tests.py test_*.py *_tests.py
3-
4-
;https://github.com/bigsassy/pytest-pythonpath#usage
5-
python_paths = tests/
6-
74
addopts = --ds=tests.settings
8-
95
norecursedirs = django_apscheduler

requirements/local.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# Testing
44
# ------------------------------------------------------------------------------
5-
pytest~=6.2 # https://github.com/pytest-dev/pytest
5+
tox==4.19.0 # https://github.com/tox-dev/tox
6+
pytest>7.0.0 # https://github.com/pytest-dev/pytest
67
pytest-sugar~=0.9 # https://github.com/Frozenball/pytest-sugar
7-
pytest-pythonpath~=0.7 # https://github.com/bigsassy/pytest-pythonpath
88

99
# Django
1010
# ------------------------------------------------------------------------------

setup.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setup(
1111
name="django-apscheduler",
12-
version="0.6.2",
12+
version="0.7.0",
1313
description="APScheduler for Django",
1414
long_description=long_description,
1515
long_description_content_type="text/markdown",
@@ -26,17 +26,19 @@
2626
"Programming Language :: Python",
2727
"Programming Language :: Python :: 3",
2828
"Programming Language :: Python :: 3 :: Only",
29-
"Programming Language :: Python :: 3.8",
3029
"Programming Language :: Python :: 3.9",
3130
"Programming Language :: Python :: 3.10",
31+
"Programming Language :: Python :: 3.11",
32+
"Programming Language :: Python :: 3.12",
3233
"Framework :: Django",
33-
"Framework :: Django :: 3.2",
34-
"Framework :: Django :: 4.0",
34+
"Framework :: Django :: 4.2",
35+
"Framework :: Django :: 5.0",
36+
"Framework :: Django :: 5.1",
3537
],
3638
keywords="django apscheduler django-apscheduler",
3739
packages=find_packages(exclude=("tests",)),
3840
install_requires=[
39-
"django>=3.2",
41+
"django>=4.2",
4042
"apscheduler>=3.2,<4.0",
4143
],
4244
zip_safe=False,

tests/test_jobstores.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def test_update_job_does_retry_on_db_operational_error(self, jobstore, create_jo
237237
with mock.patch.object(db.connection, "close") as close_mock:
238238
with pytest.raises(db.OperationalError, match="Some DB-related error"):
239239
with mock.patch(
240-
"django_apscheduler.jobstores.DjangoJob.objects.get",
240+
"django_apscheduler.jobstores.DjangoJob.objects.select_for_update",
241241
side_effect=conftest.raise_db_operational_error,
242242
):
243243
jobstore.update_job(job)
@@ -249,7 +249,7 @@ def test_remove_job_does_retry_on_db_operational_error(self, jobstore):
249249
with mock.patch.object(db.connection, "close") as close_mock:
250250
with pytest.raises(db.OperationalError, match="Some DB-related error"):
251251
with mock.patch(
252-
"django_apscheduler.jobstores.DjangoJob.objects.get",
252+
"django_apscheduler.jobstores.DjangoJob.objects.select_for_update",
253253
side_effect=conftest.raise_db_operational_error,
254254
):
255255
jobstore.remove_job("some job")

tox.ini

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[tox]
2+
envlist =
3+
{py39}-{django42}
4+
{py310}-{django42,django50,django51,djangomain}
5+
{py311}-{django42,django50,django51,djangomain}
6+
{py312}-{django42,django50,django51,djangomain}
7+
8+
[testenv]
9+
setenv =
10+
PYTHONPATH = {toxinidir}
11+
deps =
12+
pytest
13+
pytest-django
14+
django42: django>=4.2,<5.0
15+
django50: django>=5.0,<5.1
16+
django51: django>=5.1,<5.2
17+
djangomain: https://github.com/django/django/archive/main.tar.gz
18+
commands =
19+
pytest

0 commit comments

Comments
 (0)