Lee-W commented on code in PR #36840:
URL: https://github.com/apache/airflow/pull/36840#discussion_r1455735439


##########
airflow/sensors/filesystem.py:
##########
@@ -75,3 +92,20 @@ def poke(self, context: Context):
                 if files:
                     return True
         return False
+
+    def execute(self, context: Context) -> None:
+        if self.deferrable and not self.poke(context=context):
+            self.defer(
+                timeout=datetime.timedelta(seconds=self.timeout),
+                trigger=FileTrigger(
+                    filepath=self.path,
+                    recursive=self.recursive,
+                    poke_interval=self.poke_interval,
+                ),
+                method_name="execute_complete",
+            )

Review Comment:
   ```suggestion
           if not self.deferrable:
               super().execute(context=context)
           elif not self.poke(context=context):
               self.defer(
                   timeout=datetime.timedelta(seconds=self.timeout),
                   trigger=FileTrigger(
                       filepath=self.path,
                       recursive=self.recursive,
                       poke_interval=self.poke_interval,
                   ),
                   method_name="execute_complete",
               )
   ```
   ```suggestion
           if self.deferrable and not self.poke(context=context):
               self.defer(
                   timeout=datetime.timedelta(seconds=self.timeout),
                   trigger=FileTrigger(
                       filepath=self.path,
                       recursive=self.recursive,
                       poke_interval=self.poke_interval,
                   ),
                   method_name="execute_complete",
               )
   ```
   
   Should we try something like this instead? Otherwise, non-deferred mode 
might only poke once



##########
airflow/triggers/file.py:
##########
@@ -34,18 +36,29 @@ class FileTrigger(BaseTrigger):
         be a glob.
     :param recursive: when set to ``True``, enables recursive directory 
matching behavior of
         ``**`` in glob filepath parameter. Defaults to ``False``.
+    param poke_interval: Time that the job should wait in between each try
     """
 
     def __init__(
         self,
         filepath: str,
         recursive: bool = False,
-        poll_interval: float = 5.0,
+        poke_interval: float = 5.0,
+        **kwargs,
     ):
         super().__init__()
         self.filepath = filepath
         self.recursive = recursive
-        self.poll_interval = poll_interval
+        if kwargs.get("poll_interval") is not None:
+            warnings.warn(
+                "`poll_interval` has been deprecated and will be removed in 
future."
+                "Please use `poke_interval_interval` instead.",

Review Comment:
   ```suggestion
                   "Please use `poke_interval` instead.",
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to