Ensure integrations quickstart connection closed#8
Conversation
|
|
||
|
|
||
| @contextmanager | ||
| def open_datadog_connection(): |
There was a problem hiding this comment.
Any hesitation with switching urllib if it's not a difficult lift?
There was a problem hiding this comment.
Some preliminary research suggests that urllib does not support persistent connections, which this currently is. Re-using the connection should allow for lower latency so I'm a bit reluctant to give it up.
I should say though that I'm not deeply knowledgeable on the topic and did not make the original call to implement it this way.
984d58d to
ebd76a5
Compare
6b0537e to
921703e
Compare
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
Summary
I noticed some logs indicating that our rapid service had a bunch of stale connections open. After taking a look at the script, I realized that we would fail to close our connection to that service if we encountered any kind of error before completing the flow, including a SIGINT.
The pythonic way to handle this kind of thing is with a context manager, so that's what I've introduced here.
Testing
I added a print statement immediately before closing the connecting to make sure we were hitting that block when we should:

Note that the connection is closed immediately after the SIGINT