allegro / bigcache

Efficient cache for gigabytes of data written in Go.
http://allegro.tech/2016/03/writing-fast-cache-service-in-go.html
Apache License 2.0
7.45k stars 593 forks source link

Stop printing message when doing a context shutdown #374

Open rubenv opened 12 months ago

rubenv commented 12 months ago

Uses the configured logger instead.

cristaloleg commented 12 months ago

Good catch, thanks!

cristaloleg commented 12 months ago

Probably this was the reason :) https://github.com/allegro/bigcache/actions/runs/6145556141/job/16673759956?pr=374#step:5:25

rubenv commented 12 months ago

I honestly have no idea why it would cause that.

cristaloleg commented 12 months ago

AFAIR it's because during a test run os.Stdout is replaced with a test-specific writer to catch the full output. And because this we're logging in a goroutine we can log after a test end, which results in a panic due to Go test cleanup.

If you're curious to fix it than try to replace this context with context.WithCancel(...) https://github.com/allegro/bigcache/blob/157556c5afaeebd739cdbff4755e65f88a5d95af/examples_test.go#L63

And if you're not curious (which is fine too) I will take a look later today (leaving PR open for some time).

Thanks.

janisz commented 10 months ago

@rubenv Ping