@@ -173,6 +173,8 @@ def __init__(self,
173
173
"actions-queued" : 0 }
174
174
self .server_status = {"status" : "Never contacted" ,
175
175
"endpoint" : self .endpoint }
176
+ self .sync_started = False
177
+ self .sync_ended = False
176
178
if auth :
177
179
self .auth = auth
178
180
elif auth_dict :
@@ -369,7 +371,7 @@ def execute_multiple(self, actions, immediate=True):
369
371
Execute multiple Actions (each containing commands on a single object).
370
372
Normally, the actions are sent for execution immediately (possibly preceded
371
373
by earlier queued commands), but if you are going for maximum efficiency
372
- you can set immeediate =False which will cause the connection to wait
374
+ you can set immediate =False which will cause the connection to wait
373
375
and batch as many actions as allowed in each server call.
374
376
375
377
Since any command can fill the current batch, one or more of your commands may be submitted
@@ -431,6 +433,16 @@ def execute_multiple(self, actions, immediate=True):
431
433
raise BatchError (exceptions , queued , sent , completed )
432
434
return queued , sent , completed
433
435
436
+ def start_sync (self ):
437
+ """Signal the beginning of a sync operation
438
+ Sends a header with the first batch of UMAPI actions"""
439
+ self .sync_started = True
440
+
441
+ def end_sync (self ):
442
+ """Signal the end of a sync operation
443
+ Sends a header with the next batch of UMAPI actions"""
444
+ self .sync_ended = True
445
+
434
446
def _execute_batch (self , actions ):
435
447
"""
436
448
Execute a single batch of Actions.
@@ -467,10 +479,20 @@ def make_call(self, path, body=None, delete=False):
467
479
:return: the requests.result object (on 200 response), raise error otherwise
468
480
"""
469
481
if body :
482
+ extra_headers = {}
483
+ # if the sync_started or sync_ended flags are set, send a header on this POST
484
+ if self .sync_started :
485
+ self .logger .info ("Sending start_sync signal" )
486
+ extra_headers ['Pragma' ] = 'umapi-sync-start'
487
+ self .sync_started = False
488
+ elif self .sync_ended :
489
+ self .logger .info ("Sending end_sync signal" )
490
+ extra_headers ['Pragma' ] = 'umapi-sync-end'
491
+ self .sync_ended = False
470
492
request_body = json .dumps (body )
471
493
def call ():
472
494
return self .session .post (self .endpoint + path , auth = self .auth , data = request_body , timeout = self .timeout ,
473
- verify = self .ssl_verify )
495
+ verify = self .ssl_verify , headers = extra_headers )
474
496
else :
475
497
if not delete :
476
498
def call ():
0 commit comments