-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Checking Pub / Sub Batch.will_accept in thread-safe way.
#4616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| # in a separate thread. | ||
|
|
||
| # Sleep for however long we should be waiting. | ||
| time.sleep(self._settings.max_latency) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| def test_publish_max_messages(): | ||
| batch = create_batch(max_messages=4) | ||
| def test_publish_not_will_accept(): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| # If this message will make the batch exceed the ``max_bytes`` | ||
| # setting, return False. | ||
| if self.size + message.ByteSize() > self.settings.max_bytes: | ||
| if self.size + message.ByteSize() >= self.settings.max_bytes: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| f = futures.Future() | ||
| self._futures.append(f) | ||
| return f | ||
| return future |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| name='Thread-CommitBatchPublisher', | ||
| target=batch._commit, | ||
| ) | ||
| Thread.return_value.start.assert_called_once_with() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Unit tests will be coming in the next commit. Fixes googleapis#4575.
- Changing back `>=` to `>` (I was misreading a `curr_size + EXTRA > MAX` as `curr_size > MAX`) - Putting `assert_*()` calls on `Thread` mock back in the context manager
435cd08 to
cbaea8b
Compare
Unit tests will be coming in the next commit.
Fixes #4575.