From 52a6b1b2fc3eaf3cda5594825f3c5a9ae8a9452b Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Wed, 27 Oct 2021 22:42:07 +0300 Subject: Make sure events bus properly closed Signed-off-by: Valery Piashchynski --- worker/worker.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'worker') diff --git a/worker/worker.go b/worker/worker.go index 5973adc6..05c6dd0d 100755 --- a/worker/worker.go +++ b/worker/worker.go @@ -135,6 +135,7 @@ func (w *Process) Wait() error { const op = errors.Op("process_wait") var err error err = w.cmd.Wait() + defer w.events.Unsubscribe(w.eventsID) // If worker was destroyed, just exit if w.State().Value() == StateDestroyed { @@ -162,8 +163,6 @@ func (w *Process) Wait() error { return nil } - w.events.Unsubscribe(w.eventsID) - return err } @@ -221,11 +220,6 @@ func (w *Process) Kill() error { // Worker stderr func (w *Process) Write(p []byte) (n int, err error) { - w.events.Send(&events.RREvent{ - T: events.EventWorkerStderr, - P: workerEventsName, - M: utils.AsString(p), - }) - + w.events.Send(events.NewEvent(events.EventWorkerStderr, workerEventsName, utils.AsString(p))) return len(p), nil } -- cgit v1.2.3