small refactorings
This commit is contained in:
parent
aaa4390c1d
commit
8cbb99ad5e
@ -27,6 +27,10 @@ class MBWrapper:
|
||||
self.callback = callback
|
||||
self.verbose = verbose
|
||||
|
||||
def print(self, *msg):
|
||||
if self.verbose:
|
||||
print(*msg)
|
||||
|
||||
def setup_sender(self):
|
||||
assert self._type != 'receiver', 'MBWrapper is already a receiver. Use another MBWrapper.'
|
||||
self._type = 'sender'
|
||||
@ -61,10 +65,6 @@ class MBWrapper:
|
||||
def close(self):
|
||||
self._connection.close()
|
||||
|
||||
def print(self, *msg):
|
||||
if self.verbose:
|
||||
print(*msg)
|
||||
|
||||
def _setup_channel(self):
|
||||
self._connection = pika.BlockingConnection(
|
||||
pika.ConnectionParameters(host=self.host))
|
||||
@ -73,4 +73,7 @@ class MBWrapper:
|
||||
self._channel.exchange_declare(exchange=self.exchange_name, exchange_type=self.exchange_type)
|
||||
|
||||
def _receive(self, ch, method, properties, body):
|
||||
"""
|
||||
Reduce complexity, only forward the message body to the callback method
|
||||
"""
|
||||
self.callback(body)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user