potiuk commented on a change in pull request #6596: [AIRFLOW-6004] Untangle 
Executors class to avoid cyclic imports
URL: https://github.com/apache/airflow/pull/6596#discussion_r352304421
 
 

 ##########
 File path: airflow/executors/local_executor.py
 ##########
 @@ -201,31 +273,50 @@ def sync(self):
                     break
 
         def end(self):
-            # Sending poison pill to all worker
+            """Ends the executor. Sends the poison pill to all workers."""
             for _ in self.executor.workers:
                 self.queue.put((None, None))
 
             # Wait for commands to finish
             self.queue.join()
             self.executor.sync()
 
-    def start(self):
-        self.manager = multiprocessing.Manager()
+    def start(self) -> None:
+        """Starts the executor"""
+        self.manager = Manager()
         self.result_queue = self.manager.Queue()
         self.workers = []
         self.workers_used = 0
         self.workers_active = 0
-        self.impl = (LocalExecutor._UnlimitedParallelism(self) if 
self.parallelism == 0
-                     else LocalExecutor._LimitedParallelism(self))
+        self.impl = (LocalExecutor.UnlimitedParallelism(self) if 
self.parallelism == 0
+                     else LocalExecutor.LimitedParallelism(self))
 
         self.impl.start()
 
-    def execute_async(self, key, command, queue=None, executor_config=None):
-        self.impl.execute_async(key=key, command=command)
+    def execute_async(self, key: TaskInstanceKey,
+                      command: CommandType,
+                      executor_config: Optional[Any] = None) -> None:
+        """Execute asynchronously."""
+        if not self.impl:
+            raise AirflowException(NOT_STARTED_MESSAGE)
+        self.impl.execute_async(key=key, command=command, 
executor_config=executor_config)
 
-    def sync(self):
+    def sync(self) -> None:
+        """
+        Sync will get called periodically by the heartbeat method.
+        """
+        if not self.impl:
+            raise AirflowException(NOT_STARTED_MESSAGE)
         self.impl.sync()
 
-    def end(self):
+    def end(self) -> None:
+        """
+        Ends the executor.
+        :return:
+        """
+        if not self.impl:
+            raise AirflowException("Executor should be started first")
         self.impl.end()
+        if not self.manager:
+            raise AirflowException("Executor should be started first")
 
 Review comment:
   Right :)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to