diff --git a/platypush/backend/http/app/utils/__init__.py b/platypush/backend/http/app/utils/__init__.py index cad44b26..ab19ce73 100644 --- a/platypush/backend/http/app/utils/__init__.py +++ b/platypush/backend/http/app/utils/__init__.py @@ -4,7 +4,7 @@ from .auth import ( authenticate_user_pass, get_auth_status, ) -from .bus import bus, get_message_response, send_message, send_request +from .bus import bus, send_message, send_request from .logger import logger from .routes import ( get_http_port, @@ -25,7 +25,6 @@ __all__ = [ 'get_http_port', 'get_ip_or_hostname', 'get_local_base_url', - 'get_message_response', 'get_remote_base_url', 'get_routes', 'get_streaming_routes', diff --git a/platypush/backend/http/app/utils/bus.py b/platypush/backend/http/app/utils/bus.py index 6571599e..72f85658 100644 --- a/platypush/backend/http/app/utils/bus.py +++ b/platypush/backend/http/app/utils/bus.py @@ -1,11 +1,9 @@ -from redis import Redis - from platypush.bus.redis import RedisBus from platypush.config import Config from platypush.context import get_backend from platypush.message import Message from platypush.message.request import Request -from platypush.utils import get_redis_conf, get_redis_queue_name_by_message +from platypush.utils import get_redis_conf, get_message_response from .logger import logger @@ -67,24 +65,3 @@ def send_request(action, wait_for_response=True, **kwargs): msg['args'] = kwargs return send_message(msg, wait_for_response=wait_for_response) - - -def get_message_response(msg): - """ - Get the response to the given message. - - :param msg: The message to get the response for. - :return: The response to the given message. - """ - redis = Redis(**bus().redis_args) - redis_queue = get_redis_queue_name_by_message(msg) - if not redis_queue: - return None - - response = redis.blpop(redis_queue, timeout=60) - if response and len(response) > 1: - response = Message.build(response[1]) - else: - response = None - - return response diff --git a/platypush/utils/__init__.py b/platypush/utils/__init__.py index 45ffbedb..52516221 100644 --- a/platypush/utils/__init__.py +++ b/platypush/utils/__init__.py @@ -662,4 +662,27 @@ def is_root() -> bool: return os.getuid() == 0 +def get_message_response(msg): + """ + Get the response to the given message. + + :param msg: The message to get the response for. + :return: The response to the given message. + """ + from platypush.message import Message + + redis = get_redis() + redis_queue = get_redis_queue_name_by_message(msg) + if not redis_queue: + return None + + response = redis.blpop(redis_queue, timeout=60) + if response and len(response) > 1: + response = Message.build(response[1]) + else: + response = None + + return response + + # vim:sw=4:ts=4:et: