Browse Source

Refactor and add a check around a variable

Changed serializer to self._serializer, to be able to access it
from other places in the engine class. Added a check to make sure
it doesn't get created twice.

Change-Id: Ia4007a5f98af04677b2006a88b66cbf8ceec2982
Pranesh Pandurangan 4 years ago
parent
commit
1a860ac47b
1 changed files with 6 additions and 2 deletions
  1. 6
    2
      entropy/engine.py

+ 6
- 2
entropy/engine.py View File

@@ -77,6 +77,9 @@ class Engine(object):
77 77
         # Watchdog-related variables
78 78
         self._watchdog_thread = None
79 79
 
80
+        # Serializer related variables
81
+        self._serializer = None
82
+
80 83
         LOG.info('Created engine obj %s', self.name)
81 84
 
82 85
     # TODO(praneshp): Move to utils?
@@ -106,8 +109,9 @@ class Engine(object):
106 109
         self.start_scheduler()
107 110
 
108 111
     def start_scheduler(self):
109
-        serializer = self.executor.submit(self.start_serializer)
110
-        self.futures.append(serializer)
112
+        if not self._serializer:
113
+            self._serializer = self.executor.submit(self.start_serializer)
114
+            self.futures.append(self._serializer)
111 115
 
112 116
         # Start react scripts.
113 117
         self.futures.extend(self.start_react_scripts())

Loading…
Cancel
Save