Skip to content

Commit

Permalink
Delete messages from batch after successful commit API return.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Mar 18, 2015
1 parent 301ea73 commit 9cd9cf6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions gcloud/pubsub/test_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def test_publish_multiple(self):
batch.publish(PAYLOAD1)
batch.publish(PAYLOAD2, attr1='value1', attr2='value2')
self.assertEqual(list(batch), [MSGID1, MSGID2])
self.assertEqual(list(batch.messages), [])
self.assertEqual(len(conn._requested), 1)
req = conn._requested[0]
self.assertEqual(req['method'], 'POST')
Expand Down
3 changes: 2 additions & 1 deletion gcloud/pubsub/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,6 @@ def commit(self):
conn = self.topic.connection
response = conn.api_request(method='POST',
path='%s:publish' % self.topic.path,
data={'messages': self.messages})
data={'messages': self.messages[:]})
self.message_ids.extend(response['messageIds'])
del self.messages[:]

0 comments on commit 9cd9cf6

Please sign in to comment.