瀏覽代碼

cycle: continue even no mechanisms but break if no behaviour

Bastien Sevajol 7 年之前
父節點
當前提交
1b8ab31f8a
共有 1 個文件被更改,包括 17 次插入15 次删除
  1. 17 15
      synergine2/cycle.py

+ 17 - 15
synergine2/cycle.py 查看文件

@@ -198,20 +198,19 @@ class CycleManager(object):
198 198
 
199 199
         for subject in subjects:
200 200
             mechanisms = self.get_mechanisms_to_compute(subject)
201
-            if not mechanisms:
202
-                break
203
-
204
-            self.logger.info('Subject {}: {} mechanisms'.format(
205
-                str(subject.id),
206
-                str(len(mechanisms)),
207
-            ))
208 201
 
209
-            if self.logger.is_debug:
210
-                self.logger.info('Subject {}: mechanisms are: {}'.format(
202
+            if mechanisms:
203
+                self.logger.info('Subject {}: {} mechanisms'.format(
211 204
                     str(subject.id),
212
-                    str([m.repr_debug for m in mechanisms])
205
+                    str(len(mechanisms)),
213 206
                 ))
214 207
 
208
+                if self.logger.is_debug:
209
+                    self.logger.info('Subject {}: mechanisms are: {}'.format(
210
+                        str(subject.id),
211
+                        str([m.repr_debug for m in mechanisms])
212
+                    ))
213
+
215 214
             mechanisms_data = {}
216 215
             behaviours_data = {}
217 216
 
@@ -226,13 +225,16 @@ class CycleManager(object):
226 225
 
227 226
                 mechanisms_data[type(mechanism)] = mechanism_data
228 227
 
229
-            if self.logger.is_debug:
230
-                self.logger.info('Subject {}: mechanisms data are: {}'.format(
231
-                    str(subject.id),
232
-                    str(mechanisms_data),
233
-                ))
228
+            if mechanisms:
229
+                if self.logger.is_debug:
230
+                    self.logger.info('Subject {}: mechanisms data are: {}'.format(
231
+                        str(subject.id),
232
+                        str(mechanisms_data),
233
+                    ))
234 234
 
235 235
             subject_behaviours = self.get_behaviours_to_compute(subject)
236
+            if not subject_behaviours:
237
+                break
236 238
 
237 239
             self.logger.info('Subject {}: have {} behaviours'.format(
238 240
                 str(subject.id),