Protect the code when open-nti close  connections
Protect the code when open-nti close  connections

It seems in specific platforms a race condition could arise with threads and closing connections

Similar problems found at

https://rbcommons.com/s/twitter/r/3278/diff/2/
https://github.com/segmentio/analytics-python/issues/69
https://datastax-oss.atlassian.net/browse/PYTHON-232
Juniper/open-nti,Juniper/open-nti,Juniper/open-nti