-
Notifications
You must be signed in to change notification settings - Fork 232
/
azure.servicebus.aio.AutoLockRenewer.yml
104 lines (95 loc) · 5.11 KB
/
azure.servicebus.aio.AutoLockRenewer.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
### YamlMime:PythonClass
uid: azure.servicebus.aio.AutoLockRenewer
name: AutoLockRenewer
fullName: azure.servicebus.aio.AutoLockRenewer
module: azure.servicebus.aio
inheritances:
- builtins.object
summary: 'Auto lock renew.
An asynchronous AutoLockRenewer handler for renewing the lock
tokens of messages and/or sessions in the background.'
constructor:
syntax: 'AutoLockRenewer(max_lock_renewal_duration: float = 300, on_lock_renew_failure:
Callable[[ServiceBusSession | ServiceBusReceivedMessage, Exception | None], Awaitable[None]]
| None = None, loop: AbstractEventLoop | None = None)'
parameters:
- name: max_lock_renewal_duration
description: 'A time in seconds that locks registered to this renewer
should be maintained for. Default value is 300 (5 minutes).'
defaultValue: '300'
types:
- <xref:float>
- name: on_lock_renew_failure
description: 'A callback may be specified to be called when the lock is lost on
the renewable
that is being registered. Default value is None (no callback).'
defaultValue: None
types:
- <xref:typing.Optional>[<xref:LockRenewFailureCallback>]
- name: loop
defaultValue: None
examples:
- "Automatically renew a message lock<!--[!code-python[Main](les\\async_samples\\\
sample_code_servicebus_async.py )]-->\n\n<!-- literal_block {\"ids\": [], \"classes\"\
: [], \"names\": [], \"dupnames\": [], \"backrefs\": [], \"source\": \"C:\\\\hostedtoolcache\\\
\\windows\\\\Python\\\\3.11.9\\\\x64\\\\Lib\\\\site-packages\\\\py2docfx\\\\dist_temp\\\
\\221\\\\azure-servicebus-7.12.2\\\\samples\\\\async_samples\\\\sample_code_servicebus_async.py\"\
, \"xml:space\": \"preserve\", \"force\": false, \"language\": \"python\", \"highlight_args\"\
: {\"linenostart\": 1}, \"linenos\": false} -->\n\n````python\n\n from azure.servicebus.aio\
\ import AutoLockRenewer\n\n lock_renewal = AutoLockRenewer()\n async with servicebus_receiver:\n\
\ async for message in servicebus_receiver:\n lock_renewal.register(servicebus_receiver,\
\ message, max_lock_renewal_duration=60)\n await process_message(message)\n\
\ await servicebus_receiver.complete_message(message)\n\n ````\n\nAutomatically\
\ renew a session lock<!--[!code-python[Main](les\\async_samples\\sample_code_servicebus_async.py\
\ )]-->\n\n<!-- literal_block {\"ids\": [], \"classes\": [], \"names\": [], \"dupnames\"\
: [], \"backrefs\": [], \"source\": \"C:\\\\hostedtoolcache\\\\windows\\\\Python\\\
\\3.11.9\\\\x64\\\\Lib\\\\site-packages\\\\py2docfx\\\\dist_temp\\\\221\\\\azure-servicebus-7.12.2\\\
\\samples\\\\async_samples\\\\sample_code_servicebus_async.py\", \"xml:space\":\
\ \"preserve\", \"force\": false, \"language\": \"python\", \"highlight_args\":\
\ {\"linenostart\": 1}, \"linenos\": false} -->\n\n````python\n\n from azure.servicebus.aio\
\ import AutoLockRenewer\n\n lock_renewal = AutoLockRenewer()\n async\
\ with servicebus_client.get_queue_receiver(queue_name=queue_name, session_id=session_id)\
\ as receiver:\n session = receiver.session\n # Auto renew session\
\ lock for 2 minutes\n lock_renewal.register(receiver, session, max_lock_renewal_duration=120)\n\
\ async for message in receiver:\n await process_message(message)\n\
\ await receiver.complete_message(message)\n\n ````\n"
methods:
- uid: azure.servicebus.aio.AutoLockRenewer.close
name: close
summary: Cease autorenewal by cancelling any remaining open lock renewal futures.
signature: async close() -> None
- uid: azure.servicebus.aio.AutoLockRenewer.register
name: register
summary: Register a renewable entity for automatic lock renewal.
signature: 'register(receiver: ServiceBusReceiver, renewable: ServiceBusReceivedMessage
| ServiceBusSession, max_lock_renewal_duration: float | None = None, on_lock_renew_failure:
Callable[[ServiceBusSession | ServiceBusReceivedMessage, Exception | None], Awaitable[None]]
| None = None) -> None'
parameters:
- name: receiver
description: 'The ServiceBusReceiver instance that is associated with the message
or the session to
be auto-lock-renewed.'
isRequired: true
types:
- <xref:azure.servicebus.aio.ServiceBusReceiver>
- name: renewable
description: A locked entity that needs to be renewed.
isRequired: true
types:
- <xref:typing.Union>[<xref:azure.servicebus.aio.ServiceBusReceivedMessage>,<xref:azure.servicebus.aio.ServiceBusSession>]
- name: max_lock_renewal_duration
description: 'A time in seconds that the lock should be maintained for.
Default value is None. If specified, this value will override the default value
specified at the constructor.'
defaultValue: None
types:
- <xref:typing.Optional>[<xref:float>]
- name: on_lock_renew_failure
description: 'An async callback may be specified to be called when the lock is
lost on the renewable being registered.
Default value is None (no callback).
:rtype: None'
defaultValue: None
types:
- <xref:typing.Optional>[<xref:AsyncLockRenewFailureCallback>]