Skip to content

Commit

Permalink
Revert change and annotate create_mq_connection as always returning…
Browse files Browse the repository at this point in the history
… a BlockingConnection for compat. with existing usage
  • Loading branch information
NeonDaniel committed Jan 20, 2025
1 parent cd6386a commit 1e4ccbd
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions neon_mq_connector/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ def create_unique_id():

@classmethod
def emit_mq_message(cls,
connection: pika.BlockingConnection,
connection: Union[pika.BlockingConnection,
pika.SelectConnection],
request_data: dict,
exchange: Optional[str] = '',
queue: Optional[str] = '',
Expand Down Expand Up @@ -389,22 +390,19 @@ def send_message(self,
return msg_id

@retry(use_self=True, num_retries=__run_retries__)
def create_mq_connection(self, vhost: str = '/', **kwargs):
def create_mq_connection(self, vhost: str = '/',
**kwargs) -> pika.BlockingConnection:
"""
Creates MQ Connection on the specified virtual host
Note: Additional parameters can be defined via kwargs.
Creates a Blocking MQ Connection on the specified virtual host
Note: Additional parameters can be defined via kwargs.
:param vhost: address for desired virtual host
:raises Exception if self.config is not set
:param vhost: address for desired virtual host
:raises Exception if self.config is not set
"""
if not self.config:
raise Exception('Configuration is not set')
if self.async_consumers_enabled:
return pika.SelectConnection(
parameters=self.get_connection_params(vhost, **kwargs))
else:
return pika.BlockingConnection(
parameters=self.get_connection_params(vhost, **kwargs))
return pika.BlockingConnection(
parameters=self.get_connection_params(vhost, **kwargs))

def register_consumer(self, name: str, vhost: str, queue: str,
callback: callable,
Expand Down

0 comments on commit 1e4ccbd

Please sign in to comment.