Increase connection timeout and handle lock better in poll mode.

This makes the following changes:

 * increase the db connection timeout to 10s (from default 5s)
 * catch errors raised by db locking and carry on if in polling mode
 * if final poll has been reached and db locking has occurred then print the db locking error