Fixes a boundary case where the WQ master can get stuck if there
are only finished tasks to retrieve and nothing else happening in the system.
Replaced boilerplate.
Merge pull request #485 from dthain/master

Fix Work Queue hang when there are only finished tasks to retrieve.