Added retry loop to threaded db ops.
While in right place
Merge pull request #388 from arjclark/db-locking-improve

db locking mitigation
cylc/cylc#204: suite env file: initial implementation.