plain.jobs 0.36.2__tar.gz → 0.37.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of plain.jobs might be problematic. Click here for more details.

Files changed (33) hide show
  1. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/PKG-INFO +1 -1
  2. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/CHANGELOG.md +21 -0
  3. plain_jobs-0.37.0/plain/jobs/__init__.py +5 -0
  4. plain_jobs-0.37.0/plain/jobs/middleware.py +42 -0
  5. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/workers.py +4 -2
  6. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/pyproject.toml +1 -1
  7. plain_jobs-0.36.2/plain/jobs/__init__.py +0 -4
  8. plain_jobs-0.36.2/plain/jobs/middleware.py +0 -20
  9. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/.gitignore +0 -0
  10. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/LICENSE +0 -0
  11. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/README.md +0 -0
  12. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/README.md +0 -0
  13. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/admin.py +0 -0
  14. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/chores.py +0 -0
  15. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/cli.py +0 -0
  16. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/config.py +0 -0
  17. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/default_settings.py +0 -0
  18. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/jobs.py +0 -0
  19. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/migrations/0001_initial.py +0 -0
  20. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/migrations/0002_job_span_id_job_trace_id_jobrequest_span_id_and_more.py +0 -0
  21. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/migrations/0003_rename_job_jobprocess_and_more.py +0 -0
  22. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/migrations/0004_rename_tables_to_plainjobs.py +0 -0
  23. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/migrations/0005_rename_constraints_and_indexes.py +0 -0
  24. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/migrations/0006_alter_jobprocess_table_alter_jobrequest_table_and_more.py +0 -0
  25. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/migrations/__init__.py +0 -0
  26. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/models.py +0 -0
  27. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/parameters.py +0 -0
  28. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/registry.py +0 -0
  29. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/scheduling.py +0 -0
  30. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/plain/jobs/templates/admin/plainqueue/jobresult_detail.html +0 -0
  31. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/tests/app/settings.py +0 -0
  32. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/tests/test_parameters.py +0 -0
  33. {plain_jobs-0.36.2 → plain_jobs-0.37.0}/tests/test_scheduling.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain.jobs
3
- Version: 0.36.2
3
+ Version: 0.37.0
4
4
  Summary: Process background jobs with a database-driven job queue.
5
5
  Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
6
  License-File: LICENSE
@@ -1,5 +1,26 @@
1
1
  # plain-jobs changelog
2
2
 
3
+ ## [0.37.0](https://github.com/dropseed/plain/releases/plain-jobs@0.37.0) (2025-10-22)
4
+
5
+ ### What's changed
6
+
7
+ - Added `JobMiddleware` abstract base class for creating custom job middleware ([29e5c6df1a](https://github.com/dropseed/plain/commit/29e5c6df1a))
8
+ - Changed "preparing to execute job" log message from `logger.info` to `logger.debug` to reduce log noise ([8e25856639](https://github.com/dropseed/plain/commit/8e25856639))
9
+
10
+ ### Upgrade instructions
11
+
12
+ - If you have custom job middleware, update them to inherit from `JobMiddleware` and implement the `process_job()` method instead of `__call__()`
13
+
14
+ ## [0.36.3](https://github.com/dropseed/plain/releases/plain-jobs@0.36.3) (2025-10-20)
15
+
16
+ ### What's changed
17
+
18
+ - Added garbage collection back to worker processes after job completion to help manage memory usage ([aafe3ace02](https://github.com/dropseed/plain/commit/aafe3ace02))
19
+
20
+ ### Upgrade instructions
21
+
22
+ - No changes required
23
+
3
24
  ## [0.36.2](https://github.com/dropseed/plain/releases/plain-jobs@0.36.2) (2025-10-20)
4
25
 
5
26
  ### What's changed
@@ -0,0 +1,5 @@
1
+ from .jobs import Job
2
+ from .middleware import JobMiddleware
3
+ from .registry import register_job
4
+
5
+ __all__ = ["Job", "JobMiddleware", "register_job"]
@@ -0,0 +1,42 @@
1
+ from __future__ import annotations
2
+
3
+ from abc import ABC, abstractmethod
4
+ from collections.abc import Callable
5
+ from typing import TYPE_CHECKING
6
+
7
+ from plain.logs import app_logger
8
+
9
+ if TYPE_CHECKING:
10
+ from .models import JobProcess, JobResult
11
+
12
+
13
+ class JobMiddleware(ABC):
14
+ """
15
+ Abstract base class for job middleware.
16
+
17
+ Subclasses must implement process_job() to handle the job execution cycle.
18
+
19
+ Example:
20
+ class MyJobMiddleware(JobMiddleware):
21
+ def process_job(self, job: JobProcess) -> JobResult:
22
+ # Pre-processing
23
+ result = self.run_job(job)
24
+ # Post-processing
25
+ return result
26
+ """
27
+
28
+ def __init__(self, run_job: Callable[[JobProcess], JobResult]):
29
+ self.run_job = run_job
30
+
31
+ @abstractmethod
32
+ def process_job(self, job: JobProcess) -> JobResult:
33
+ """Process the job and return a result. Must be implemented by subclasses."""
34
+ ...
35
+
36
+
37
+ class AppLoggerMiddleware(JobMiddleware):
38
+ def process_job(self, job: JobProcess) -> JobResult:
39
+ with app_logger.include_context(
40
+ job_request_uuid=str(job.job_request_uuid), job_process_uuid=str(job.uuid)
41
+ ):
42
+ return self.run_job(job)
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import gc
3
4
  import logging
4
5
  import multiprocessing
5
6
  import os
@@ -143,7 +144,7 @@ class Worker:
143
144
  time.sleep(1)
144
145
  continue
145
146
 
146
- logger.info(
147
+ logger.debug(
147
148
  'Preparing to execute job job_class=%s job_request_uuid=%s job_priority=%s job_source="%s" job_queues="%s"',
148
149
  job_request.job_class,
149
150
  job_request.uuid,
@@ -326,7 +327,7 @@ def process_job(job_process_uuid: str) -> None:
326
327
  for middleware_path in reversed(settings.JOBS_MIDDLEWARE):
327
328
  middleware_class = import_string(middleware_path)
328
329
  middleware_instance = middleware_class(middleware_chain)
329
- middleware_chain = middleware_instance
330
+ middleware_chain = middleware_instance.process_job
330
331
 
331
332
  job_result = middleware_chain(job_process)
332
333
 
@@ -353,3 +354,4 @@ def process_job(job_process_uuid: str) -> None:
353
354
  logger.exception(e)
354
355
  finally:
355
356
  request_finished.send(sender=None)
357
+ gc.collect()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "plain.jobs"
3
- version = "0.36.2"
3
+ version = "0.37.0"
4
4
  description = "Process background jobs with a database-driven job queue."
5
5
  authors = [{name = "Dave Gaeddert", email = "dave.gaeddert@dropseed.dev"}]
6
6
  readme = "README.md"
@@ -1,4 +0,0 @@
1
- from .jobs import Job
2
- from .registry import register_job
3
-
4
- __all__ = ["Job", "register_job"]
@@ -1,20 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from collections.abc import Callable
4
- from typing import TYPE_CHECKING
5
-
6
- from plain.logs import app_logger
7
-
8
- if TYPE_CHECKING:
9
- from .models import JobProcess, JobResult
10
-
11
-
12
- class AppLoggerMiddleware:
13
- def __init__(self, run_job: Callable[[JobProcess], JobResult]) -> None:
14
- self.run_job = run_job
15
-
16
- def __call__(self, job: JobProcess) -> JobResult:
17
- with app_logger.include_context(
18
- job_request_uuid=str(job.job_request_uuid), job_process_uuid=str(job.uuid)
19
- ):
20
- return self.run_job(job)
File without changes
File without changes
File without changes