Skip to content

Commit

Permalink
Update logging
Browse files Browse the repository at this point in the history
Annotate `NeonMQHandler` class and explicitly disable async consumers
  • Loading branch information
NeonDaniel committed Jan 20, 2025
1 parent 6260da6 commit adf0e78
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion neon_mq_connector/consumers/select_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self,
self._loop = get_event_loop()
self.__stop_loop_on_exit = False
except RuntimeError as e:
LOG.info(e)
LOG.info(f"Creating a new event loop: e={e}")
self._loop = new_event_loop()
set_event_loop(self._loop)
self._loop.run_forever()
Expand Down
8 changes: 8 additions & 0 deletions neon_mq_connector/utils/client_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@


class NeonMQHandler(MQConnector):
"""
This class is intended for use with `send_mq_request` for simple,
transactional reqeusts. Applications needing a persistent connection to
MQ services should implement `MQConnector` directly.
"""

async_consumers_enabled = False

def __init__(self, config: dict, service_name: str, vhost: str):
super().__init__(config, service_name)
self.vhost = vhost
Expand Down
8 changes: 4 additions & 4 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
import pytest
import pika

from threading import Thread

from threading import Thread, Event

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

Expand Down Expand Up @@ -137,7 +136,7 @@ def setUp(self) -> None:
@classmethod
def tearDownClass(cls) -> None:
if cls.test_connector is not None:
cls.test_connector.stop_consumers()
cls.test_connector.stop()

def test_send_mq_request_valid(self):
from neon_mq_connector.utils.client_utils import send_mq_request
Expand Down Expand Up @@ -190,7 +189,8 @@ def check_response(name: str):
for p in processes:
p.join(60)

self.assertEqual(len(processes), len(responses))
self.assertEqual(len(processes), len(responses),
f"len(responses)={len(responses)}")
for resp in responses.values():
self.assertTrue(resp['success'], resp.get('reason'))

Expand Down

0 comments on commit adf0e78

Please sign in to comment.