|
38 | 38 | from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
|
39 | 39 |
|
40 | 40 | DLP_JOB_PATH_PATTERN = "^projects/[^/]+/dlpJobs/(?P<job>.*?)$"
|
41 |
| -# Time to sleep between active checks of the operation results |
42 |
| -TIME_TO_SLEEP_IN_SECONDS = 1 |
43 | 41 |
|
44 | 42 |
|
45 | 43 | # pylint: disable=R0904, C0302
|
@@ -180,6 +178,7 @@ def create_dlp_job(
|
180 | 178 | timeout: Optional[float] = None,
|
181 | 179 | metadata: Optional[Sequence[Tuple[str, str]]] = None,
|
182 | 180 | wait_until_finished: bool = True,
|
| 181 | + time_to_sleep_in_seconds: int = 60 |
183 | 182 | ) -> DlpJob:
|
184 | 183 | """
|
185 | 184 | Creates a new job to inspect storage or calculate risk metrics.
|
@@ -207,6 +206,9 @@ def create_dlp_job(
|
207 | 206 | until it is set to DONE.
|
208 | 207 | :type wait_until_finished: bool
|
209 | 208 | :rtype: google.cloud.dlp_v2.types.DlpJob
|
| 209 | + :param time_to_sleep_in_seconds: (Optional) Time to sleep, in seconds, between active checks |
| 210 | + of the operation results. Defaults to 60. |
| 211 | + :type time_to_sleep_in_seconds: int |
210 | 212 | """
|
211 | 213 |
|
212 | 214 | client = self.get_conn()
|
@@ -242,7 +244,7 @@ def create_dlp_job(
|
242 | 244 | DlpJob.JobState.RUNNING,
|
243 | 245 | DlpJob.JobState.JOB_STATE_UNSPECIFIED,
|
244 | 246 | ]:
|
245 |
| - time.sleep(TIME_TO_SLEEP_IN_SECONDS) |
| 247 | + time.sleep(time_to_sleep_in_seconds) |
246 | 248 | else:
|
247 | 249 | raise AirflowException(
|
248 | 250 | "Stopped polling DLP job state. DLP job {} state: {}.".format(
|
|
0 commit comments