File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33# Standard library imports
44import json
5+ import os
56import time
67from abc import ABC , abstractmethod
78
@@ -114,6 +115,14 @@ def __init__(self) -> None:
114115 f"Django project not correctly configured. { e } "
115116 ) from None
116117
118+ # Parse environment variables
119+ try :
120+ self ._env_flag = "-p-" if os .environ ["ENV" ] == "prod" else "-t-"
121+ except KeyError as e :
122+ raise RuntimeError (
123+ f'Missing required environment variable "{ e } ". '
124+ ) from None
125+
117126 # List project queues
118127 try :
119128 self ._queues = self .list_names ()
@@ -202,7 +211,7 @@ def get_name(self, source: str) -> str:
202211 return matches [0 ]
203212
204213 def list_names (self ) -> list [str ]:
205- """Fetches the names of all queues in the current project.
214+ """Fetches the names of all queues in the current project environment .
206215
207216 NOTE: Names are fully-qualified and have the format:
208217 `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
@@ -239,7 +248,11 @@ def list_names(self) -> list[str]:
239248 )
240249
241250 # Return names
242- return [queue ["name" ] for queue in r .json ()["queues" ]]
251+ return [
252+ queue ["name" ]
253+ for queue in r .json ()["queues" ]
254+ if self ._env_flag in queue ["name" ]
255+ ]
243256
244257 def purge (self ) -> None :
245258 """Purges all tasks from the configured queues.
You can’t perform that action at this time.
0 commit comments