diff options
| author | Paul Buetow <paul@buetow.org> | 2025-03-24 17:22:48 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-03-24 17:22:48 +0200 |
| commit | ec72ef1e68cdbd6938c713294dab97ecee25dc68 (patch) | |
| tree | 2a108729cd933646f4e80f800ef1fbecb414d103 | |
| parent | d4738888bc71e7aaa45d911b3fc3e3f6905ce9fd (diff) | |
fix termination of the event loop
| -rw-r--r-- | internal/eventloop.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/internal/eventloop.go b/internal/eventloop.go index ae3f887..0be7b7e 100644 --- a/internal/eventloop.go +++ b/internal/eventloop.go @@ -51,7 +51,7 @@ func newEventLoop(flags flags.Flags) *eventLoop { } func (e *eventLoop) stats() string { - fmt.Println("Waiting for staps to be ready") + fmt.Println("Waiting for stats to be ready") <-e.done duration := time.Since(e.startTime) @@ -111,13 +111,11 @@ func (e *eventLoop) events(ctx context.Context, rawCh <-chan []byte) <-chan *eve continue } e.processRawEvent(raw, ch) + case <-ctx.Done(): + fmt.Println("Stopping event loop") + return default: - select { - case <-ctx.Done(): - return - default: - time.Sleep(time.Millisecond * 10) - } + time.Sleep(time.Millisecond * 10) } } }() |
