52
52
LOG = logging .getLogger (__name__ )
53
53
54
54
55
- class Task ( object ) :
55
+ class Task :
56
56
"""Run a command on the eventloop thread, wait until it completes
57
57
"""
58
58
@@ -74,7 +74,7 @@ class SubscribeTask(Task):
74
74
arriving from the target are given to the listener.
75
75
"""
76
76
def __init__ (self , target , listener , notifications = False ):
77
- super (SubscribeTask , self ).__init__ ()
77
+ super ().__init__ ()
78
78
self ._target = target () # mutable - need a copy
79
79
self ._subscriber_id = listener .id
80
80
self ._in_queue = listener .incoming
@@ -95,7 +95,7 @@ class SendTask(Task):
95
95
"""
96
96
def __init__ (self , name , message , target , deadline , retry ,
97
97
wait_for_ack , notification = False ):
98
- super (SendTask , self ).__init__ ()
98
+ super ().__init__ ()
99
99
self .name = name
100
100
# note: target can be either a Target class or a string
101
101
# target is mutable - make copy
@@ -195,18 +195,18 @@ class RPCCallTask(SendTask):
195
195
the destination.
196
196
"""
197
197
def __init__ (self , target , message , deadline , retry , wait_for_ack ):
198
- super (RPCCallTask , self ).__init__ ("RPC Call" , message , target ,
199
- deadline , retry , wait_for_ack )
198
+ super ().__init__ ("RPC Call" , message , target ,
199
+ deadline , retry , wait_for_ack )
200
200
self ._reply_link = None
201
201
self ._reply_msg = None
202
202
self ._msg_id = None
203
203
204
204
def wait (self ):
205
- error = super (RPCCallTask , self ).wait ()
205
+ error = super ().wait ()
206
206
return error or self ._reply_msg
207
207
208
208
def _prepare (self , sender ):
209
- super (RPCCallTask , self )._prepare (sender )
209
+ super ()._prepare (sender )
210
210
# reserve a message id for mapping the received response
211
211
if self ._msg_id :
212
212
# already set so this is a re-transmit. To be safe cancel the old
@@ -224,15 +224,15 @@ def _on_reply(self, message):
224
224
225
225
def _on_ack (self , state , info ):
226
226
if state != pyngus .SenderLink .ACCEPTED :
227
- super (RPCCallTask , self )._on_ack (state , info )
227
+ super ()._on_ack (state , info )
228
228
# must wait for reply if ACCEPTED
229
229
230
230
def _cleanup (self ):
231
231
if self ._msg_id :
232
232
self ._reply_link .cancel_response (self ._msg_id )
233
233
self ._msg_id = None
234
234
self ._reply_link = None
235
- super (RPCCallTask , self )._cleanup ()
235
+ super ()._cleanup ()
236
236
237
237
238
238
class RPCMonitoredCallTask (RPCCallTask ):
@@ -243,8 +243,8 @@ class RPCMonitoredCallTask(RPCCallTask):
243
243
"""
244
244
def __init__ (self , target , message , deadline , call_monitor_timeout ,
245
245
retry , wait_for_ack ):
246
- super (RPCMonitoredCallTask , self ).__init__ (target , message , deadline ,
247
- retry , wait_for_ack )
246
+ super ().__init__ (target , message , deadline ,
247
+ retry , wait_for_ack )
248
248
assert call_monitor_timeout is not None # nosec
249
249
self ._monitor_timeout = call_monitor_timeout
250
250
self ._monitor_timer = None
@@ -254,7 +254,7 @@ def _execute(self, controller):
254
254
self ._set_alarm = controller .processor .defer
255
255
self ._monitor_timer = self ._set_alarm (self ._call_timeout ,
256
256
self ._monitor_timeout )
257
- super (RPCMonitoredCallTask , self )._execute (controller )
257
+ super ()._execute (controller )
258
258
259
259
def _call_timeout (self ):
260
260
# monitor_timeout expired
@@ -274,22 +274,22 @@ def _on_reply(self, message):
274
274
self ._monitor_timer = self ._set_alarm (self ._call_timeout ,
275
275
self ._monitor_timeout )
276
276
else :
277
- super (RPCMonitoredCallTask , self )._on_reply (message )
277
+ super ()._on_reply (message )
278
278
279
279
def _cleanup (self ):
280
280
self ._set_alarm = None
281
281
if self ._monitor_timer :
282
282
self ._monitor_timer .cancel ()
283
283
self ._monitor_timer = None
284
- super (RPCMonitoredCallTask , self )._cleanup ()
284
+ super ()._cleanup ()
285
285
286
286
287
287
class MessageDispositionTask (Task ):
288
288
"""A task that updates the message disposition as accepted or released
289
289
for a Server
290
290
"""
291
291
def __init__ (self , disposition , released = False ):
292
- super (MessageDispositionTask , self ).__init__ ()
292
+ super ().__init__ ()
293
293
self ._disposition = disposition
294
294
self ._released = released
295
295
@@ -311,7 +311,7 @@ class Sender(pyngus.SenderEventHandler):
311
311
"""A link for sending to a particular destination on the message bus.
312
312
"""
313
313
def __init__ (self , destination , scheduler , delay , service ):
314
- super (Sender , self ).__init__ ()
314
+ super ().__init__ ()
315
315
self ._destination = destination
316
316
self ._service = service
317
317
self ._address = None
@@ -537,8 +537,8 @@ def _send_pending(self):
537
537
self ._send (self ._pending_sends .popleft ())
538
538
539
539
def _open_link (self ):
540
- name = "openstack.org/om/sender/[%s]/%s" % (self ._address ,
541
- uuid .uuid4 ().hex )
540
+ name = "openstack.org/om/sender/[{}]/{}" . format (self ._address ,
541
+ uuid .uuid4 ().hex )
542
542
link = self ._connection .create_sender (name = name ,
543
543
source_address = self ._address ,
544
544
target_address = self ._address ,
@@ -685,7 +685,8 @@ def attach(self, connection):
685
685
"""
686
686
self ._connection = connection
687
687
for a in self ._addresses :
688
- name = "openstack.org/om/receiver/[%s]/%s" % (a , uuid .uuid4 ().hex )
688
+ name = "openstack.org/om/receiver/[{}]/{}" .format (
689
+ a , uuid .uuid4 ().hex )
689
690
r = self ._open_link (a , name )
690
691
self ._receivers .append (r )
691
692
@@ -786,8 +787,8 @@ def _reopen_links(self):
786
787
class RPCServer (Server ):
787
788
"""Subscribes to RPC addresses"""
788
789
def __init__ (self , target , incoming , scheduler , delay , capacity ):
789
- super (RPCServer , self ).__init__ (target , incoming , scheduler , delay ,
790
- capacity )
790
+ super ().__init__ (target , incoming , scheduler , delay ,
791
+ capacity )
791
792
792
793
def attach (self , connection , addresser ):
793
794
# Generate the AMQP 1.0 addresses for the base class
@@ -797,25 +798,25 @@ def attach(self, connection, addresser):
797
798
addresser .anycast_address (self ._target , SERVICE_RPC )
798
799
]
799
800
# now invoke the base class with the generated addresses
800
- super (RPCServer , self ).attach (connection )
801
+ super ().attach (connection )
801
802
802
803
803
804
class NotificationServer (Server ):
804
805
"""Subscribes to Notification addresses"""
805
806
def __init__ (self , target , incoming , scheduler , delay , capacity ):
806
- super (NotificationServer , self ).__init__ (target , incoming , scheduler ,
807
- delay , capacity )
807
+ super ().__init__ (target , incoming , scheduler ,
808
+ delay , capacity )
808
809
809
810
def attach (self , connection , addresser ):
810
811
# Generate the AMQP 1.0 addresses for the base class
811
812
self ._addresses = [
812
813
addresser .anycast_address (self ._target , SERVICE_NOTIFY )
813
814
]
814
815
# now invoke the base class with the generated addresses
815
- super (NotificationServer , self ).attach (connection )
816
+ super ().attach (connection )
816
817
817
818
818
- class Hosts ( object ) :
819
+ class Hosts :
819
820
"""An order list of TransportHost addresses. Connection failover progresses
820
821
from one host to the next. The default realm comes from the configuration
821
822
and is only used if no realm is present in the URL.
0 commit comments