kbaseapps / DataFileUtil

MIT License
0 stars 12 forks source link

Close socket #64

Closed Tianhao-Gu closed 5 years ago

MrCreosote commented 5 years ago

Would a with work better here?

Tianhao-Gu commented 5 years ago

Would a with work better here?

Tianhao-Gu commented 5 years ago

@MrCreosote using with requests. There are two requests in try-except block. I think using response.close() is more clean.

MrCreosote commented 5 years ago

with ensures that whatever happens in the block, the socket is closed. If you don't use with and there's an error in the block prior to the close call you'll leak sockets

Tianhao-Gu commented 5 years ago

@MrCreosote Sure. Updated all requests using with.

MrCreosote commented 5 years ago

LGTM