Joffreybvn commented on code in PR #34964:
URL: https://github.com/apache/airflow/pull/34964#discussion_r1369648913


##########
airflow/models/baseoperator.py:
##########
@@ -1218,15 +1225,17 @@ def __deepcopy__(self, memo):
         result.__instantiated = self.__instantiated
         return result
 
-    def __getstate__(self):
+    def __getstate__(self) -> dict:
         state = dict(self.__dict__)
-        del state["_log"]
+        state["_log"] = self._log.name if self._log else None

Review Comment:
   Here I want to store whenever a logger has already been initialized or not 
(`_log`is not initialized by default anymore with this PR). If not, I don't 
restore it in setstate.
   
   Instead of a flag, storing the name covers also the case where `_log` is set 
up in any other way than by the LoggingMixing. Right now, no operators is 
setting `_log` directly, but other classes in Airflow codebase do.
   
   If we assume the LoggingMixin always define the `_log` for operators, then I 
can indeed store a flag instead of the name.



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to