Skip to content

panic if Run and Stop race #868

@twmb

Description

@twmb

internal_worker.AggregatedWorker#Run calls aw.Start, which asserts that the worker has not yet been stopped.

Run is a blocking function, it must be executed in a goroutine if the user wants to stop the worker independently. The user may then wait for an input signal and Stop the worker. It is possible that Run has not yet started and Stop executes before Run. In this tight sequence of events, the code will panic:

panic("attempted to start a worker that has been stopped before")

Since Run returns an error, I'd expect this code to just return ErrClosed or something similar.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions