@@ -236,7 +236,7 @@ def begin(self):
236
236
raise ValueError ("Batch already started previously." )
237
237
self ._status = self ._IN_PROGRESS
238
238
239
- def _commit (self ):
239
+ def _commit (self , retry , timeout ):
240
240
"""Commits the batch.
241
241
242
242
This is called by :meth:`commit`.
@@ -246,8 +246,16 @@ def _commit(self):
246
246
else :
247
247
mode = _datastore_pb2 .CommitRequest .TRANSACTIONAL
248
248
249
+ kwargs = {}
250
+
251
+ if retry is not None :
252
+ kwargs ["retry" ] = retry
253
+
254
+ if timeout is not None :
255
+ kwargs ["timeout" ] = timeout
256
+
249
257
commit_response_pb = self ._client ._datastore_api .commit (
250
- self .project , mode , self ._mutations , transaction = self ._id
258
+ self .project , mode , self ._mutations , transaction = self ._id , ** kwargs
251
259
)
252
260
_ , updated_keys = _parse_commit_response (commit_response_pb )
253
261
# If the back-end returns without error, we are guaranteed that
@@ -257,21 +265,32 @@ def _commit(self):
257
265
new_id = new_key_pb .path [- 1 ].id
258
266
entity .key = entity .key .completed_key (new_id )
259
267
260
- def commit (self ):
268
+ def commit (self , retry = None , timeout = None ):
261
269
"""Commits the batch.
262
270
263
271
This is called automatically upon exiting a with statement,
264
272
however it can be called explicitly if you don't want to use a
265
273
context manager.
266
274
275
+ :type retry: :class:`google.api_core.retry.Retry`
276
+ :param retry:
277
+ A retry object used to retry requests. If ``None`` is specified,
278
+ requests will be retried using a default configuration.
279
+
280
+ :type timeout: float
281
+ :param timeout:
282
+ Time, in seconds, to wait for the request to complete.
283
+ Note that if ``retry`` is specified, the timeout applies
284
+ to each individual attempt.
285
+
267
286
:raises: :class:`~exceptions.ValueError` if the batch is not
268
287
in progress.
269
288
"""
270
289
if self ._status != self ._IN_PROGRESS :
271
290
raise ValueError ("Batch must be in progress to commit()" )
272
291
273
292
try :
274
- self ._commit ()
293
+ self ._commit (retry = retry , timeout = timeout )
275
294
finally :
276
295
self ._status = self ._FINISHED
277
296
0 commit comments