Skip to content
Snippets Groups Projects
Commit 299e8007 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

SW-772: improved tmp exchange/queue names

parent 2d510fb4
No related branches found
No related tags found
1 merge request!8Cobalt2 multithreading fix
...@@ -187,6 +187,7 @@ some.event bar ...@@ -187,6 +187,7 @@ some.event bar
""" """
from lofar.messaging.exceptions import * from lofar.messaging.exceptions import *
from lofar.messaging import adaptNameToEnvironment
from lofar.messaging.messages import * from lofar.messaging.messages import *
from lofar.messaging.config import DEFAULT_BROKER, DEFAULT_BUSNAME, DEFAULT_PORT, DEFAULT_USER, DEFAULT_PASSWORD from lofar.messaging.config import DEFAULT_BROKER, DEFAULT_BUSNAME, DEFAULT_PORT, DEFAULT_USER, DEFAULT_PASSWORD
from lofar.common.threading_utils import TimeoutLock from lofar.common.threading_utils import TimeoutLock
...@@ -807,8 +808,8 @@ class TemporaryExchange: ...@@ -807,8 +808,8 @@ class TemporaryExchange:
It is advised to use the TemporaryExchange instance in a 'with' context, which guarantees the close call. It is advised to use the TemporaryExchange instance in a 'with' context, which guarantees the close call.
""" """
# create an identifiable address based on the given name which is also (almost) unique, and readable. # create an identifiable address based on the given name which is also (almost) unique, and readable.
self.address = "%stmp-exchange-%s" % (self._name_prefix+"-" if self._name_prefix else "", self.address = adaptNameToEnvironment("%stmp-exchange-%s" % (self._name_prefix+"-" if self._name_prefix else "",
uuid.uuid4().hex[:8]) uuid.uuid4().hex[:8]))
logger.debug("Creating TemporaryExchange at %s ...", self.address) logger.debug("Creating TemporaryExchange at %s ...", self.address)
create_exchange(name=self.address, broker=self.broker) create_exchange(name=self.address, broker=self.broker)
logger.debug("Created TemporaryExchange at %s", self.address) logger.debug("Created TemporaryExchange at %s", self.address)
...@@ -937,8 +938,8 @@ class TemporaryQueue: ...@@ -937,8 +938,8 @@ class TemporaryQueue:
It is advised to use the TemporaryQueue instance in a 'with' context, which guarantees the close call. It is advised to use the TemporaryQueue instance in a 'with' context, which guarantees the close call.
""" """
# create an identifiable address based on the given name which is also (almost) unique, and readable. # create an identifiable address based on the given name which is also (almost) unique, and readable.
self.address = "%stmp-queue-%s" % (self._name_prefix+"-" if self._name_prefix else "", self.address = adaptNameToEnvironment("%stmp-queue-%s" % (self._name_prefix+"-" if self._name_prefix else "",
uuid.uuid4().hex[:8]) uuid.uuid4().hex[:8]))
logger.debug("Creating TemporaryQueue at %s ...", self.address) logger.debug("Creating TemporaryQueue at %s ...", self.address)
if not self._bound_exchange: if not self._bound_exchange:
......
...@@ -64,6 +64,7 @@ from lofar.messaging.config import DEFAULT_BROKER, DEFAULT_BUSNAME ...@@ -64,6 +64,7 @@ from lofar.messaging.config import DEFAULT_BROKER, DEFAULT_BUSNAME
from lofar.messaging.messagebus import ToBus, BusListener, AbstractMessageHandler, UsingToBusMixin, TemporaryQueue from lofar.messaging.messagebus import ToBus, BusListener, AbstractMessageHandler, UsingToBusMixin, TemporaryQueue
from lofar.messaging.messages import LofarMessage, MessageFactory from lofar.messaging.messages import LofarMessage, MessageFactory
from lofar.messaging.exceptions import MessagingError from lofar.messaging.exceptions import MessagingError
from lofar.common.util import program_name
from typing import Optional from typing import Optional
from datetime import datetime, timedelta from datetime import datetime, timedelta
import logging import logging
...@@ -336,7 +337,7 @@ class RPCClient(): ...@@ -336,7 +337,7 @@ class RPCClient():
broker = self._request_sender.broker broker = self._request_sender.broker
# setup a temporary queue on which we can receive the answer from the service # setup a temporary queue on which we can receive the answer from the service
with TemporaryQueue(name_prefix="rpc-reply-for-" + self._service_name, with TemporaryQueue(name_prefix="rpc-reply-for-%s-%s" % (program_name(include_extension=False), self._service_name),
exchange=exchange, exchange=exchange,
broker=broker, broker=broker,
addressed_to_me_only=True) as tmp_reply_queue: addressed_to_me_only=True) as tmp_reply_queue:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment