missing connection check before returning it

checking if the connection still exists solved lots of random AttributeError exceptions 'NoneType' object has no attribute 'lock'

looking few lines up seems like this check is necessary
Merge pull request #31 from tbarbugli/patch-1

missing connection check before returning it