jrallison/go-workers — pull request #9 by nono (2013-09-11 15:06:20+00:00)
Title: Don't open so many connections to redis

Hi,

I'm trying to use go-workers, but I have some issues. One of them is that go-workers open so many connections to redis that it fails (lookup localhost: too many open files). I think it's because `defer` is not used correctly.

The `defer` statement is executed when the surrounding function returns. In `fetcher.go`, it opens a new connection at each iteration in the `for` loop, but the `Close` are defered until the fetch is closed and the surrounding function returns.

In `scheduled.go`, the `defer` is never called, except with a panic, because the surrouding function calls itself and so never returns.

I'm not sure if my patch is correct, but it's better than now. What do you think?