@@ -21,7 +21,7 @@ class Queue(object):
2121 # of Queue in the current process
2222 known_queues = {}
2323
24- def __init__ (self , queue_id , add_to_known_queues = True ):
24+ def __init__ (self , queue_id , add_to_known_queues = False ):
2525
2626 if isinstance (queue_id , Queue ):
2727 self .id = queue_id .id # TODO use __new__?
@@ -110,7 +110,7 @@ def redis_known_subqueues(self):
110110
111111 for key in Queue .known_queues :
112112 if key .startswith (self .id ) and not key .endswith (delimiter ):
113- queues .append (Queue (key ))
113+ queues .append (Queue (key , add_to_known_queues = True ))
114114
115115 return queues
116116
@@ -235,11 +235,35 @@ def all_active(cls):
235235 return queues
236236
237237 @classmethod
238- def all_known (cls , ):
238+ def all_known (cls ):
239239 """ List all previously known queues """
240240
241- # raw queues we know exist from the config + known queues in redis
242- return set (context .get_current_config ().get ("raw_queues" , {}).keys () + cls .redis_known_queues ().keys ())
241+ # queues we know exist from the config + known queues in redis
242+ return cls .all_known_from_config ().union (set (cls .redis_known_queues ().keys ()))
243+
244+ @classmethod
245+ def all_known_from_config (cls ):
246+ """ List all known queues from config (raw and regular). Caution: this does not account for the
247+ configuration of workers' queues (usually given via command line)
248+ """
249+
250+ cfg = context .get_current_config ()
251+
252+ queues_from_config = [
253+ t .get ("queue" )
254+ for t in (cfg .get ("tasks" ) or {}).values ()
255+ if t .get ("queue" )
256+ ]
257+
258+ queues_from_config += (cfg .get ("raw_queues" ) or {}).keys ()
259+
260+ queues_from_config += [
261+ t .get ("retry_queue" )
262+ for t in (cfg .get ("raw_queues" ) or {}).values ()
263+ if t .get ("retry_queue" )
264+ ]
265+
266+ return set (queues_from_config )
243267
244268 @classmethod
245269 def all (cls ):
0 commit comments