Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for processing. Default is 300.
:type prefetch: int
:param epoch: An optional epoch value.
:type epoch: int
:param loop: An event loop.
"""
self.loop = loop or asyncio.get_event_loop()
self.running = False
self.client = client
self.source = source
self.offset = offset
self.prefetch = prefetch
self.epoch = epoch
self.keep_alive = keep_alive
self.auto_reconnect = auto_reconnect
self.retry_policy = errors.ErrorPolicy(max_retries=3, on_error=_error_handler)
self.reconnect_backoff = 1
self.redirected = None
self.error = None
self.properties = None
partition = self.source.split('/')[-1]
self.name = "EHReceiver-{}-partition{}".format(uuid.uuid4(), partition)
source = Source(self.source)
if self.offset is not None:
source.set_filter(self.offset.selector())
if epoch:
self.properties = {types.AMQPSymbol(self._epoch): types.AMQPLong(int(epoch))}
self._handler = ReceiveClientAsync(
source,
auth=self.client.get_auth(),
debug=self.client.debug,
prefetch=self.prefetch,
for processing. Default is 300.
:type prefetch: int
:param epoch: An optional epoch value.
:type epoch: int
:param loop: An event loop.
"""
self.loop = loop or asyncio.get_event_loop()
self.running = False
self.client = client
self.source = source
self.offset = offset
self.prefetch = prefetch
self.epoch = epoch
self.keep_alive = keep_alive
self.auto_reconnect = auto_reconnect
self.retry_policy = errors.ErrorPolicy(max_retries=3, on_error=_error_handler)
self.reconnect_backoff = 1
self.redirected = None
self.error = None
self.properties = None
partition = self.source.split('/')[-1]
self.name = "EHReceiver-{}-partition{}".format(uuid.uuid4(), partition)
source = Source(self.source)
if self.offset is not None:
source.set_filter(self.offset.selector())
if epoch:
self.properties = {types.AMQPSymbol(self._epoch): types.AMQPLong(int(epoch))}
self._handler = ReceiveClientAsync(
source,
auth=self.client.get_auth(),
debug=self.client.debug,
prefetch=self.prefetch,
self.closed = False
self.stop = False # used by event processor
self.handler_ready = False
self._on_event_received = kwargs[
"on_event_received"
] # type: Callable[[EventData], None]
self._client = client
self._source = source
self._offset = event_position
self._offset_inclusive = kwargs.get("event_position_inclusive", False)
self._prefetch = prefetch
self._owner_level = owner_level
self._keep_alive = keep_alive
self._auto_reconnect = auto_reconnect
self._retry_policy = errors.ErrorPolicy(
max_retries=self._client._config.max_retries, on_error=_error_handler # pylint:disable=protected-access
)
self._reconnect_backoff = 1
self._link_properties = {} # type: Dict[types.AMQPType, types.AMQPType]
self._error = None
self._timeout = 0
self._idle_timeout = (idle_timeout * 1000) if idle_timeout else None
partition = self._source.split("/")[-1]
self._partition = partition
self._name = "EHConsumer-{}-partition{}".format(uuid.uuid4(), partition)
if owner_level:
self._link_properties[types.AMQPSymbol(EPOCH_SYMBOL)] = types.AMQPLong(
int(owner_level)
)
link_property_timeout_ms = (
self._client._config.receive_timeout or self._timeout # pylint:disable=protected-access
:type source: str
:param prefetch: The number of events to prefetch from the service
for processing. Default is 300.
:type prefetch: int
:param epoch: An optional epoch value.
:type epoch: int
"""
self.running = False
self.client = client
self.source = source
self.offset = offset
self.prefetch = prefetch
self.epoch = epoch
self.keep_alive = keep_alive
self.auto_reconnect = auto_reconnect
self.retry_policy = errors.ErrorPolicy(max_retries=3, on_error=_error_handler)
self.reconnect_backoff = 1
self.properties = None
self.redirected = None
self.error = None
partition = self.source.split('/')[-1]
self.name = "EHReceiver-{}-partition{}".format(uuid.uuid4(), partition)
source = Source(self.source)
if self.offset is not None:
source.set_filter(self.offset.selector())
if epoch:
self.properties = {types.AMQPSymbol(self._epoch): types.AMQPLong(int(epoch))}
self._handler = ReceiveClient(
source,
auth=self.client.get_auth(),
debug=self.client.debug,
prefetch=self.prefetch,
periods of inactivity. The default value is None, i.e. no keep alive pings.
:type keep_alive: int
:param auto_reconnect: Whether to automatically reconnect the sender if a retryable error occurs.
Default value is `True`.
:type auto_reconnect: bool
"""
self.running = False
self.client = client
self.target = target
self.partition = partition
self.timeout = send_timeout
self.redirected = None
self.error = None
self.keep_alive = keep_alive
self.auto_reconnect = auto_reconnect
self.retry_policy = errors.ErrorPolicy(max_retries=3, on_error=_error_handler)
self.reconnect_backoff = 1
self.name = "EHSender-{}".format(uuid.uuid4())
if partition:
self.target += "/Partitions/" + partition
self.name += "-partition{}".format(partition)
self._handler = SendClient(
self.target,
auth=self.client.get_auth(),
debug=self.client.debug,
msg_timeout=self.timeout,
error_policy=self.retry_policy,
keep_alive_interval=self.keep_alive,
client_name=self.name,
properties=self.client.create_properties())
self._outcome = None
self._condition = None
auto_reconnect = kwargs.get("auto_reconnect", True)
idle_timeout = kwargs.get("idle_timeout", None)
self.running = False
self.closed = False
self._max_message_size_on_link = None
self._client = client
self._target = target
self._partition = partition
self._timeout = send_timeout
self._idle_timeout = (idle_timeout * 1000) if idle_timeout else None
self._error = None
self._keep_alive = keep_alive
self._auto_reconnect = auto_reconnect
self._retry_policy = errors.ErrorPolicy(
max_retries=self._client._config.max_retries, on_error=_error_handler # pylint: disable=protected-access
)
self._reconnect_backoff = 1
self._name = "EHProducer-{}".format(uuid.uuid4())
self._unsent_events = [] # type: List[Any]
if partition:
self._target += "/Partitions/" + partition
self._name += "-partition{}".format(partition)
self._handler = None # type: Optional[SendClient]
self._outcome = None # type: Optional[constants.MessageSendResult]
self._condition = None # type: Optional[Exception]
self._lock = threading.Lock()
self._link_properties = {
types.AMQPSymbol(TIMEOUT_SYMBOL): types.AMQPLong(int(self._timeout * 1000))
}
periods of inactivity. The default value is `None`, i.e. no keep alive pings.
:type keep_alive: int
:param auto_reconnect: Whether to automatically reconnect the sender if a retryable error occurs.
Default value is `True`.
:type auto_reconnect: bool
:param loop: An event loop. If not specified the default event loop will be used.
"""
self.loop = loop or asyncio.get_event_loop()
self.running = False
self.client = client
self.target = target
self.partition = partition
self.keep_alive = keep_alive
self.auto_reconnect = auto_reconnect
self.timeout = send_timeout
self.retry_policy = errors.ErrorPolicy(max_retries=3, on_error=_error_handler)
self.reconnect_backoff = 1
self.name = "EHSender-{}".format(uuid.uuid4())
self.redirected = None
self.error = None
if partition:
self.target += "/Partitions/" + partition
self.name += "-partition{}".format(partition)
self._handler = SendClientAsync(
self.target,
auth=self.client.get_auth(),
debug=self.client.debug,
msg_timeout=self.timeout,
error_policy=self.retry_policy,
keep_alive_interval=self.keep_alive,
client_name=self.name,
properties=self.client.create_properties(),
:rtype: ~uamqp.errors.ErrorAction
"""
if error.condition == b'com.microsoft:server-busy':
return errors.ErrorAction(retry=True, backoff=4)
if error.condition == b'com.microsoft:timeout':
return errors.ErrorAction(retry=True, backoff=2)
if error.condition == b'com.microsoft:operation-cancelled':
return errors.ErrorAction(retry=True)
if error.condition == b"com.microsoft:container-close":
return errors.ErrorAction(retry=True, backoff=4)
if error.condition in _NO_RETRY_ERRORS:
return errors.ErrorAction(retry=False)
return errors.ErrorAction(retry=True)
class _ServiceBusErrorPolicy(errors.ErrorPolicy):
def __init__(self, max_retries=3, is_session=False):
self._is_session = is_session
super(_ServiceBusErrorPolicy, self).__init__(max_retries=max_retries, on_error=_error_handler)
def on_unrecognized_error(self, error):
if self._is_session:
return errors.ErrorAction(retry=False)
return super(_ServiceBusErrorPolicy, self).on_unrecognized_error(error)
def on_link_error(self, error):
if self._is_session:
return errors.ErrorAction(retry=False)
return super(_ServiceBusErrorPolicy, self).on_link_error(error)
def on_connection_error(self, error):
periods of inactivity. The default value is `None`, i.e. no keep alive pings.
:type keep_alive: int
:param auto_reconnect: Whether to automatically reconnect the sender if a retryable error occurs.
Default value is `True`.
:type auto_reconnect: bool
:param loop: An event loop. If not specified the default event loop will be used.
"""
self.loop = loop or asyncio.get_event_loop()
self.running = False
self.client = client
self.target = target
self.partition = partition
self.keep_alive = keep_alive
self.auto_reconnect = auto_reconnect
self.timeout = send_timeout
self.retry_policy = errors.ErrorPolicy(max_retries=3, on_error=_error_handler)
self.reconnect_backoff = 1
self.name = "EHSender-{}".format(uuid.uuid4())
self.redirected = None
self.error = None
if partition:
self.target += "/Partitions/" + partition
self.name += "-partition{}".format(partition)
self._handler = SendClientAsync(
self.target,
auth=self.client.get_auth(),
debug=self.client.debug,
msg_timeout=self.timeout,
error_policy=self.retry_policy,
keep_alive_interval=self.keep_alive,
client_name=self.name,
properties=self.client.create_properties(),