Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Make post_stat async #4157
Currently posting stat is synchronous so if user cannot reach the stat server, the whole operation will have to wait for timeout.
This PR changes the post action to be asynchronous. The return value is discarded (also status quo)
Existing test can be found here
It is async and does not block user actions.
This has the unfortunate effect of moving the post to a non main thread, which is not interrupted by Ctrl+C. If you are not running the daemon, this is a problem. I didn't test with the daemon, but I suspect the behavior is ok because I think the thread will run in a different process.
I tested this by starting a local http server that lets requests time out and changing the url to that with a large timeout. This causes the post to hang.
Without this change, Ctrl+C on the hanging request kills the process. With it, Ctrl+C does not interrupt the hanging request, and pants will wait the full length of the timeout.
The result looks something like this:
iiuc without being to interrupt the side thread, pants has to wait for the full timeout and is unable to exit, which is be worse than the status quo in sync fashion, correct?
I can see a couple of options:
hmm okay. the daemon thread will get killed half way when the program exits without
which circles back to the original issue: