@@ -55,19 +55,19 @@ class BaseTasqClient(metaclass=ABCMeta):
55
55
:type port: int
56
56
:param port: The port associated with the host param
57
57
58
- :type sign_data : bool or False
59
- :param sign_data : Boolean flag, sign bytes passing around through sockets
58
+ :type signkey : bool or False
59
+ :param signkey : Boolean flag, sign bytes passing around through sockets
60
60
if True
61
61
62
62
"""
63
63
64
- def __init__ (self , host , port , sign_data = False ):
64
+ def __init__ (self , host , port , signkey = None ):
65
65
# Host address of a remote supervisor to connect to
66
66
self ._host = host
67
67
# Port for push side (outgoing) of the communication channel
68
68
self ._port = port
69
69
# Send digital signed data
70
- self ._sign_data = sign_data
70
+ self ._signkey = signkey
71
71
# Client reference, set up the communication with a Supervisor
72
72
self ._client = self ._make_client ()
73
73
# Connection flag
@@ -226,8 +226,8 @@ class ZMQTasqClient(BaseTasqClient):
226
226
:type plport: int or None
227
227
:param plport: The pull port to retrieve bytes from
228
228
229
- :type sign_data : bool or False
230
- :param sign_data : Boolean flag, sign bytes passing around through sockets
229
+ :type signkey : bool or False
230
+ :param signkey : Boolean flag, sign bytes passing around through sockets
231
231
if True
232
232
233
233
:type unix_socket: bool or False
@@ -238,13 +238,13 @@ class ZMQTasqClient(BaseTasqClient):
238
238
239
239
__extraparams__ = {'plport' }
240
240
241
- def __init__ (self , host , port , plport = None , sign_data = False , unix_socket = False ):
241
+ def __init__ (self , host , port , plport = None , signkey = None , unix_socket = False ):
242
242
self ._plport = plport or port + 1
243
243
# Unix socket flag, if set to true, unix sockets for interprocess
244
244
# communication will be used and ports will be used to differentiate
245
245
# push and pull channel
246
246
self ._unix_socket = unix_socket
247
- super ().__init__ (host , port , sign_data )
247
+ super ().__init__ (host , port , signkey )
248
248
249
249
@property
250
250
def plport (self ):
@@ -259,7 +259,7 @@ def __repr__(self):
259
259
def _make_client (self ):
260
260
return ConnectionFactory \
261
261
.make_client (self .host , self .port , self .plport ,
262
- self ._sign_data , self ._unix_socket )
262
+ self ._signkey , self ._unix_socket )
263
263
264
264
def _gather_results (self ):
265
265
"""Gathering subroutine, must be run in another thread to concurrently
@@ -279,17 +279,17 @@ def _gather_results(self):
279
279
self ._log .error ("Can't update result: key not found" )
280
280
281
281
@classmethod
282
- def from_url (cls , url , sign_data = False ):
282
+ def from_url (cls , url , signkey = None ):
283
283
u = urlparse (url )
284
284
scheme = u .scheme or 'zmq'
285
285
assert scheme in ('zmq' , 'unix' , 'tcp' ), f"Unsupported { scheme } "
286
- extras = {t .split ('=' )[0 ]: t .split ('=' )[1 ] for t in u .query .split ('?' )}
286
+ extras = {t .split ('=' )[0 ]: t .split ('=' )[1 ] for t in u .query .split ('?' ) if t }
287
287
extras = {k : v for k , v in extras .items () if k in cls .__extraparams__ }
288
288
conn_args = {
289
289
'host' : u .hostname or '127.0.0.1' ,
290
290
'port' : u .port or 9000 ,
291
291
'plport' : int (extras .get ('plport' , 0 )),
292
- 'sign_data ' : sign_data ,
292
+ 'signkey ' : signkey ,
293
293
'unix_socket' : scheme == 'unix'
294
294
}
295
295
return cls (** conn_args )
@@ -314,19 +314,19 @@ class RedisTasqClient(BaseTasqClient):
314
314
:type name: str or redis-queue
315
315
:param name: The name of the redis queue
316
316
317
- :type sign_data : bool or False
318
- :param sign_data : Boolean flag, sign bytes passing around through sockets
317
+ :type signkey : bool or False
318
+ :param signkey : Boolean flag, sign bytes passing around through sockets
319
319
if True
320
320
321
321
"""
322
322
323
323
__extraparams__ = {'db' , 'name' }
324
324
325
325
def __init__ (self , host = 'localhost' , port = 6379 ,
326
- db = 0 , name = 'redis-queue' , sign_data = False ):
326
+ db = 0 , name = 'redis-queue' , signkey = None ):
327
327
self ._db = db
328
328
self ._name = name
329
- super ().__init__ (host , port , sign_data )
329
+ super ().__init__ (host , port , signkey )
330
330
331
331
@property
332
332
def name (self ):
@@ -340,7 +340,7 @@ def __repr__(self):
340
340
def _make_client (self ):
341
341
return ConnectionFactory \
342
342
.make_redis_client (self .host , self .port , self ._db ,
343
- self ._name , secure = self ._sign_data )
343
+ self ._name , signkey = self ._signkey )
344
344
345
345
def _gather_results (self ):
346
346
"""Gathering subroutine, must be run in another thread to concurrently
@@ -378,18 +378,18 @@ def disconnect(self):
378
378
self ._is_connected = False
379
379
380
380
@classmethod
381
- def from_url (cls , url , sign_data = False ):
381
+ def from_url (cls , url , signkey = None ):
382
382
u = urlparse (url )
383
383
scheme = u .scheme or 'redis'
384
384
assert scheme == 'redis' , f"Unsupported { scheme } "
385
- extras = {t .split ('=' )[0 ]: t .split ('=' )[1 ] for t in u .query .split ('?' )}
385
+ extras = {t .split ('=' )[0 ]: t .split ('=' )[1 ] for t in u .query .split ('?' ) if t }
386
386
extras = {k : v for k , v in extras .items () if k in cls .__extraparams__ }
387
387
conn_args = {
388
388
'host' : u .hostname or 'localhost' ,
389
389
'port' : u .port or 6379 ,
390
390
'db' : int (extras .get ('db' , 0 )),
391
391
'name' : extras .get ('name' , 'redis-queue' ),
392
- 'sign_data ' : sign_data
392
+ 'signkey ' : signkey
393
393
}
394
394
return cls (** conn_args )
395
395
@@ -410,18 +410,18 @@ class RabbitMQTasqClient(BaseTasqClient):
410
410
:type name: str or amqp-queue
411
411
:param name: The name of the RabbitMQ queue
412
412
413
- :type sign_data : bool or False
414
- :param sign_data : Boolean flag, sign bytes passing around through sockets
413
+ :type signkey : bool or False
414
+ :param signkey : Boolean flag, sign bytes passing around through sockets
415
415
if True
416
416
417
417
"""
418
418
419
419
__extraparams__ = {'name' }
420
420
421
421
def __init__ (self , host = 'localhost' , port = 5672 ,
422
- name = 'amqp-queue' , sign_data = False ):
422
+ name = 'amqp-queue' , signkey = None ):
423
423
self ._name = name
424
- super ().__init__ (host , port , sign_data )
424
+ super ().__init__ (host , port , signkey )
425
425
426
426
@property
427
427
def name (self ):
@@ -435,14 +435,16 @@ def __repr__(self):
435
435
def _make_client (self ):
436
436
return ConnectionFactory \
437
437
.make_rabbitmq_client (self .host , self .port , 'sender' ,
438
- self ._name , secure = self ._sign_data )
438
+ self ._name , signkey = self ._signkey )
439
439
440
440
def _gather_results (self ):
441
441
"""Gathering subroutine, must be run in another thread to concurrently
442
442
listen for results and store them into a dedicated dictionary
443
443
"""
444
444
while True :
445
445
job_result = self ._client .recv_result ()
446
+ if not job_result :
447
+ continue
446
448
self ._log .debug ("Gathered result: %s" , job_result )
447
449
try :
448
450
self ._results [job_result .name ].set_result (job_result )
@@ -468,17 +470,17 @@ def disconnect(self):
468
470
self ._is_connected = False
469
471
470
472
@classmethod
471
- def from_url (cls , url , sign_data = False ):
473
+ def from_url (cls , url , signkey = None ):
472
474
u = urlparse (url )
473
475
scheme = u .scheme or 'amqp'
474
476
assert scheme == 'amqp' , f"Unsupported { scheme } "
475
- extras = {t .split ('=' )[0 ]: t .split ('=' )[1 ] for t in u .query .split ('?' )}
477
+ extras = {t .split ('=' )[0 ]: t .split ('=' )[1 ] for t in u .query .split ('?' ) if t }
476
478
extras = {k : v for k , v in extras .items () if k in cls .__extraparams__ }
477
479
conn_args = {
478
480
'host' : u .hostname or 'localhost' ,
479
481
'port' : u .port or 5672 ,
480
482
'name' : extras .get ('name' , 'amqp-queue' ),
481
- 'sign_data ' : sign_data
483
+ 'signkey ' : signkey
482
484
}
483
485
return cls (** conn_args )
484
486
0 commit comments