Fix contention and locks issue

Hey @malthe 
please take a look at the changes below.

This PR includes your work on #1 
The changes I've made were required in order to avoid pq re-connect on every scheduled task this way exhausting any available database/pool connection.

I also updated `setup.py` to include required deps so that the tests could be run.

The benchmarks show almost no changes in performance.
Thank you in advance.