Good point. To those unaware, the time.After is equivalent to time.NewTimer(d).C, but "the underlying Timer is not recovered by the garbage collector until the timer fires" (quote from the doc).
That slowAPICall function should look like:
func slowAPICall(ctx context.Context) string {
d := rand.Intn(5)
t := time.NewTimer(time.Duration(d) * time.Second)
defer t.Stop()
...
}
There's an ugly bug in http.TimeoutHandler though - it obscures stack traces so that it's impossible to use them to locate panic in decorated handler:
https://github.com/golang/go/issues/27375
> The latter two positions say "San Francisco", but we have a growing engineering office in Berlin with people working on the live video CDN and fraud detection. These positions can be filled in Berlin and we'd be very happy to do so (helps us grow the Berlin office).
Ex-SoundClouder and Berliner here. I'm sad you haven't mentioned that in your previous comments in "Who is hiring?" threads. I once found a dead link in your comment and when I looked at job ads on your site I couldn't find any openings for Berlin.
It's hard to write an asynchronous ORM though. Your options are either to use some existing synchronous ORM (like SQLAlchemy) in a thread pool (`loop.run_in_executor`) or use more low-level db driver:
https://github.com/aio-libs/aiopg#example-of-sqlalchemy-opti...
That slowAPICall function should look like: