luketighe / IQFeed

Python - IQ DTN Feed Historical Data Download & Cache
28 stars 12 forks source link

Sockets are not properly closed #1

Open stephenrs opened 7 years ago

stephenrs commented 7 years ago

line 94 of iqfeed.py should actually be

sock.close()

Not closing socket connections can lead to problems when large numbers of symbols are downloaded at scale. I've also posted a comment to Michael Halls-Moore's original article.

Cheers!

stephenrs commented 7 years ago

I should also mention that doing a sock.shutdown() before the sock.close() is safer (and better form) than just using close() alone. Here's some info on why: https://engineering.imvu.com/2014/03/06/charming-python-how-to-actually-close-a-socket-by-calling-shutdown-before-calling-close/

luketighe commented 7 years ago

@stephenrs thanks for that. I will implement it this weekend. I found more supporting evidence on Stack Overflow in regards to close/shutdown. http://stackoverflow.com/questions/409783/socket-shutdown-vs-socket-close