Rewrote the dynamic timeout support.

- Moved the next timeout prediction into the SQL result.
- Grouped all timeout related logic inside `Queue.get()` method.
- Last timeout is successfully cached for optimization purposes.
- Removed the `NotYet` exception.
- This should fix the leaking database connections issue.
Pass the connection directly to select.
Make sure the timeout is reset back if no estimation returned.