- fix to close socket
- py3 friendly excepton