Skip to content

Commit

Permalink
Merge pull request #37 from RegioHelden/36-fix-run-consumers
Browse files Browse the repository at this point in the history
fix: prevent `DjangoKafka.run_consumers` from starting the process if…
  • Loading branch information
bodja authored Nov 13, 2024
2 parents 307c3b8 + 1dd5445 commit 1559c3c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "0.5.5"
current_version = "0.5.6"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.5.6 (2024-11-13)
* Fix `DjangoKafka.run_consumers` failing when there are no consumers in the registry.

## 0.5.5 (2024-11-06)
* `./manage.py kafka_connect` command now will exit with `CommandError` in case of any exception.
* New `@substitute_error(errors: Iterable[Type[Exception]], substitution: Type[Exception])` decorator to substitute exceptions.
Expand Down
7 changes: 5 additions & 2 deletions django_kafka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

logger = logging.getLogger(__name__)

__version__ = "0.5.5"
__version__ = "0.5.6"

__all__ = [
"autodiscover",
Expand Down Expand Up @@ -62,7 +62,10 @@ def run_consumer(self, consumer_key: str):
consumer.run()

def run_consumers(self, consumers: Optional[list[str]] = None):
consumers = consumers or list(self.consumers)
if not (consumers := consumers or list(self.consumers)):
logger.debug("No consumers in registry. Exit the process.")
return

with Pool(processes=len(consumers)) as pool:
try:
pool.map(self.run_consumer, consumers)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "django-kafka"
version = "0.5.5"
version = "0.5.6"
dependencies = [
"django>=4.0,<6.0",
"confluent-kafka[avro, schema-registry]==2.4.0"
Expand Down

0 comments on commit 1559c3c

Please sign in to comment.