Bug: Segmentation fault when using with confluent kafka consumer
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginnen Sie mit der bereitgestellten test_sample-Reproduktion unter Verwendung von KafkaContainer, confluent_kafka.Consumer, asyncio.to_thread und pytest-asyncio. Prüfen Sie das verknüpfte confluent-kafka issue auf verwandten Kontext und erfassen Sie die Versionen von Python, Docker, testcontainers-python und den Abhängigkeiten. Als erledigt gilt die Aufgabe, wenn der Test abgeschlossen wird und die pytest-Umgebung nicht mehr mit einem Segmentation Fault beendet wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
Creating an asyncio test case that uses the kafka container on completion of the test (the test itself is successful) the pytest environment segfaults.
To Reproduce
Provide a self-contained code snippet that illustrates the bug or unexpected behavior. Ideally, send a Pull Request to illustrate with a test that illustrates the problem.
import asyncio
import time
import sys
from confluent_kafka import Consumer
import pytest
from testcontainers.core.waiting_utils import wait_for_logs
from testcontainers.kafka import KafkaContainer
@pytest.fixture(scope="module")
def kafka_container():
"""Provide a temporary Redis container."""
with KafkaContainer("mirror.gcr.io/confluentinc/cp-kafka:7.6.0") as container:
wait_for_logs(container, "Awaiting socket connections on 0.0.0.0:9093")
for topic in ["mytopic"]:
container.exec(
f"kafka-topics "
f"--bootstrap-server localhost:9092 "
f"--create "
f"--topic {topic} "
f"--partitions 3 "
f"--replication-factor 1",
)
yield container
async def kafka_consumer(consumer, timeout=1.0):
while True:
msg = await asyncio.to_thread(consumer.poll, timeout=timeout)
if msg is None:
continue
if msg.error():
print("Consumer error: {}".format(msg.error()))
continue
print('Received message: {}'.format(msg.value().decode('utf-8')))
async def main(consumer):
task = asyncio.create_task(kafka_consumer(consumer))
await asyncio.sleep(10)
print("Cancelling the task...")
task.cancel()
try:
await task
except asyncio.CancelledError:
print("Task was cancelled")
@pytest.mark.asyncio(loop_scope="function")
async def test_sample(kafka_container):
consumer = Consumer({
'bootstrap.servers': kafka_container.get_bootstrap_server(),
'group.id': 'mygroup',
'auto.offset.reset': 'earliest',
"debug":"all"})
consumer.subscribe(['mytopic'])
await main(consumer)
consumer.close()
Runtime environment
Provide a summary of your runtime environment. Which operating system, python version, and docker version are you using? What is the version of testcontainers-python you are using? You can run the following commands to get the relevant information.
[project]
name = "kafka-test"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"confluent-kafka>=2.9.0",
]
[dependency-groups]
dev = [
"pytest>=8.3.5",
"pytest-asyncio>=0.26.0",
"testcontainers>=4.10.0",
]
More info
https://github.com/confluentinc/confluent-kafka-python/issues/1953#issuecomment-2784234429
- Vorherrschende Sprache
- Python
- Sterne
- 2.3k
- Forks
- 397
- Ø Merge
- 8 T. 16 Std.
- Gemergte PRs (30 T.)
- 5
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus testcontainers/testcontainers-python
-
Feature: Stream bytes out on copy_from_containerEvtl. vergeben @archit15singh hat das vor 11 Tagen übernommen. Offen🚀 enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
-
Bug: HttpWaitStrategy ignores response predicates for accepted HTTP error statusesEvtl. vergeben @PranavMulakala hat das vor 41 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
-
Bug: LogMessageWaitStrategy: a container that exits before its message raises without its logs, and __enter__ then removes the containerEvtl. vergeben @granzer69 hat das vor 42 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
testcontainers/testcontainers-python#1086 · 1 Kommentar ·
-
Bug: [minio] _healthcheck calls for nested wait_container_is_ready resulting in long wait timeOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
testcontainers/testcontainers-python#578 · 5 Kommentare ·
Alle Issues in testcontainers/testcontainers-python
Ähnliche Issues
-
bug feature request
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Qiskit/qiskit-obp#156 ·
-
action-item enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
getcommunityone/open-navigator#1658 ·
Maintainer antworten meist innerhalb von 1 Tag
-
review-panel severity:low
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
kristovatlas/coin-accounting#636 ·
Maintainer antworten meist innerhalb von 1 Tag