Fix issue with closed socket on Python 3
Fix for future division