threadmill 0.7.2__tar.gz → 0.7.3__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.
Files changed (26) hide show
  1. {threadmill-0.7.2 → threadmill-0.7.3}/PKG-INFO +1 -1
  2. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/_version.py +3 -3
  3. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/executor.py +17 -5
  4. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/management/commands/threadmill.py +2 -2
  5. {threadmill-0.7.2 → threadmill-0.7.3}/LICENSE +0 -0
  6. {threadmill-0.7.2 → threadmill-0.7.3}/README.md +0 -0
  7. {threadmill-0.7.2 → threadmill-0.7.3}/pyproject.toml +0 -0
  8. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/__init__.py +0 -0
  9. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/apps.py +0 -0
  10. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/backends/__init__.py +0 -0
  11. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/backends/base.py +0 -0
  12. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/backends/lua/acknowledge.lua +0 -0
  13. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/backends/lua/acquire.lua +0 -0
  14. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/backends/lua/mover.lua +0 -0
  15. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/backends/lua/reaper.lua +0 -0
  16. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/backends/redis.py +0 -0
  17. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/exceptions.py +0 -0
  18. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/inspector/__init__.py +0 -0
  19. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/inspector/app.py +0 -0
  20. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/inspector/inspector.scss +0 -0
  21. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/inspector/screens.py +0 -0
  22. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/inspector/telemetry.py +0 -0
  23. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/management/__init__.py +0 -0
  24. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/management/commands/__init__.py +0 -0
  25. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/retry.py +0 -0
  26. {threadmill-0.7.2 → threadmill-0.7.3}/threadmill/signals.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: threadmill
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Summary: The most reliable backend for Django's task framework.
5
5
  Keywords: Django,tasks,worker
6
6
  Author-email: Johannes Maron <johannes@maron.family>
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.7.2'
22
- __version_tuple__ = version_tuple = (0, 7, 2)
21
+ __version__ = version = '0.7.3'
22
+ __version_tuple__ = version_tuple = (0, 7, 3)
23
23
 
24
- __commit_id__ = commit_id = 'g560d3b3b5'
24
+ __commit_id__ = commit_id = 'g0eee0b8b7'
@@ -8,6 +8,7 @@ import logging
8
8
  import multiprocessing
9
9
  import random
10
10
  import socket
11
+ import sys
11
12
  import threading
12
13
  import time
13
14
  import typing
@@ -81,10 +82,21 @@ class JsonFormatter(logging.Formatter):
81
82
 
82
83
 
83
84
  logger = multiprocessing.get_logger()
84
- handler = logging.StreamHandler()
85
+ handler = logging.StreamHandler(sys.stdout)
85
86
  handler.setFormatter(JsonFormatter())
86
- logger.addHandler(handler)
87
- logger.setLevel(logging.INFO)
87
+
88
+
89
+ def configure_logging(formatter: logging.Formatter) -> None:
90
+ """Route every log record of this process through the threadmill handler."""
91
+ handler.setFormatter(formatter)
92
+ for existing_logger in logging.root.manager.loggerDict.values():
93
+ if isinstance(existing_logger, logging.Logger):
94
+ existing_logger.handlers.clear()
95
+ existing_logger.propagate = True
96
+ root_logger = logging.getLogger()
97
+ root_logger.handlers.clear()
98
+ root_logger.addHandler(handler)
99
+ root_logger.setLevel(logging.INFO)
88
100
 
89
101
 
90
102
  @dataclasses.dataclass(kw_only=True, slots=True)
@@ -138,7 +150,7 @@ class TaskExecutor:
138
150
 
139
151
  def run(self) -> None:
140
152
  """Start consuming tasks until shutdown is requested."""
141
- handler.setFormatter(self.log_formatter)
153
+ configure_logging(self.log_formatter)
142
154
  self.worker_processes = [
143
155
  self.create_worker_process() for _ in range(self.process_count)
144
156
  ]
@@ -213,8 +225,8 @@ class WorkerProcess(multiprocessing.Process):
213
225
 
214
226
  def run(self) -> None:
215
227
  """Start consumer execution inside this process."""
216
- handler.setFormatter(self.log_formatter)
217
228
  django.setup()
229
+ configure_logging(self.log_formatter)
218
230
  logger.info("Starting worker process %s", self.name)
219
231
  self.lock = threading.Lock()
220
232
  self.expired = threading.Event()
@@ -88,8 +88,8 @@ class WorkerCommand(DjangoBaseCommand):
88
88
  parser.add_argument(
89
89
  "--log-format",
90
90
  help=(
91
- "Logging format string for worker log records, e.g."
92
- " '%%(levelname)s %%(message)s'. Defaults to JSON."
91
+ "Logging format string for all log records of the worker process,"
92
+ " e.g. '%%(levelname)s %%(message)s'. Defaults to JSON."
93
93
  ),
94
94
  )
95
95
 
File without changes
File without changes
File without changes