Skip to content

Commit

Permalink
fix(test): Explicitly close kafka consumer (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker authored Feb 4, 2020
1 parent 4e2a06b commit 3c181d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions integration-test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ pytest
pytest-localserver
requests
flask
werkzeug==0.15.1
confluent-kafka
msgpack
pytest-rerunfailures
pytest-xdist
redis
pytest-xdist==1.31.0
redis==3.4.1
git+https://github.com/untitaker/pytest-sentry#egg=pytest-sentry
7 changes: 6 additions & 1 deletion tests/integration/fixtures/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ def inner(topic: str, options=None):

consumer = kafka.Consumer(settings)
consumer.subscribe(topics)
request.addfinalizer(consumer.unsubscribe)

def die():
consumer.unsubscribe()
consumer.close()

request.addfinalizer(die)

while consumer.poll(timeout=0.1) is not None:
pass
Expand Down

0 comments on commit 3c181d2

Please sign in to comment.