Skip to content

Commit 179f18c

Browse files
committed
#602 fixed a bug that fast scripts were notified about finish before start
1 parent d519350 commit 179f18c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/execution/execution_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ def start_script(self, config, user: User):
6262
config=config)
6363
self._active_executor_ids.add(execution_id)
6464

65-
self._add_post_finish_handling(execution_id, executor, user)
66-
6765
self._fire_execution_started(execution_id, user)
6866

67+
self._add_post_finish_handling(execution_id, executor, user)
68+
6969
return execution_id
7070

7171
def stop_script(self, execution_id, user):

src/tests/execution_service_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,20 @@ def test_finish_listener_by_id(self):
236236
self.get_process(id1).stop()
237237
self.assertEqual(1, len(notifications))
238238

239+
def test_start_finish_listener_order(self):
240+
executor._process_creator = create_process_wrapper
241+
242+
execution_service = self.create_execution_service()
243+
244+
notifications = []
245+
246+
execution_service.add_finish_listener(lambda _, __: notifications.append('finished'))
247+
execution_service.add_start_listener(lambda _, __: notifications.append('started'))
248+
249+
self._start(execution_service)
250+
251+
self.assertEqual(['started', 'finished'], notifications)
252+
239253
def _start(self, execution_service, user_id=DEFAULT_USER_ID):
240254
return _start(execution_service, user_id)
241255

0 commit comments

Comments
 (0)