This repository was archived by the owner on Sep 17, 2025. It is now read-only.
Flush async worker queue immediately on exit#384
Merged
c24t merged 2 commits intocensus-instrumentation:masterfrom Nov 7, 2018
Merged
Flush async worker queue immediately on exit#384c24t merged 2 commits intocensus-instrumentation:masterfrom
c24t merged 2 commits intocensus-instrumentation:masterfrom
Conversation
Member
Author
|
Compare some offending tests on this branch and master: python -m pytest -s 'tests/unit/stats/exporter/test_stackdriver_stats.py::TestStackdriverStatsExporter'On my machine this hangs for over a minute after the tests complete on master and finishes in under a second on this branch. |
Member
Author
|
Thanks @liyanhui1228. I'll make the same changes in the trace package with #386. |
Contributor
|
Thanks for this. Have we released a OC version with this change in ? |
Member
Author
|
@ocervell not yet, and we don't have an ETA for the next release. Obviously not a great solution, but if you want to use bleeding-edge unreleased changes in the meantime you can do an editable install, e.g.: pip install -e 'git+git@github.com:census-instrumentation/opencensus-python.git@32ee2c8#egg=opencensus-python' |
c24t
added a commit
to c24t/opencensus-python
that referenced
this pull request
Nov 21, 2018
c24t
added a commit
to c24t/opencensus-python
that referenced
this pull request
Nov 21, 2018
c24t
added a commit
that referenced
this pull request
Nov 28, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This diff changes the behavior of
AsyncTransportsuch that its worker thread starts exporting items in its queue immediately when the process exits.Currently the worker thread exports a batch of items from the queue at an interval of
_WAIT_PERIOD, and waits for up tograce_periodon exit to finish draining the queue. Since we don't trigger an export on exit this means that the thread can block for up to_WAIT_PERIODbefore doing any work, while preventing the process from exiting.#354 changed
_WAIT_PERIODfrom 1s to 60s. The defaultgrace_periodis 5s. Before #354, any process that spawned a worker thread to be killed on exit would block for up to 1s (plus the time to export pending items), after the change these processes would block for up to 5s. As a result, tests that created a lot ofAsyncTransports-- likeTestStackdriverStatsExporter-- would block for a long time on exit.I think this is the behavior we want, but it is a significant change. On exit, the transport will now export data in a tight loop for up to
grace_period, when before it would never export items at a rate faster thanbatch_size / _WAIT_PERIOD.