@@ -1512,9 +1512,13 @@ def create_invitation(self, workspace_id: int, email: str, workspace_role: Works
15121512 ws_inv = self .post (f"v2/workspaces/{ workspace_id } /invitations" , params , json_headers )
15131513 return json .load (ws_inv )
15141514
1515- def _sync_project_generator (self , project_directory ):
1515+ def sync_project_generator (self , project_directory ):
15161516 """
1517- See `sync_project` for details. This method is a generator yielding upload progress as (size_change, job) tuples.
1517+ Syncs project by loop with these steps:
1518+ 1. Pull server version
1519+ 2. Get local changes
1520+ 3. Push first change batch
1521+ Repeat if there are more local changes.
15181522
15191523 :param project_directory: Project's directory
15201524 """
@@ -1527,6 +1531,7 @@ def _sync_project_generator(self, project_directory):
15271531 job = push_project_async (self , project_directory )
15281532 if not job :
15291533 break
1534+ # waiting for progress
15301535 last_size = 0
15311536 while push_project_is_running (job ):
15321537 sleep (SYNC_CALLBACK_WAIT )
@@ -1549,35 +1554,11 @@ def _sync_project_generator(self, project_directory):
15491554
15501555 def sync_project (self , project_directory ):
15511556 """
1552- Syncs project by loop with these steps:
1553- 1. Pull server version
1554- 2. Get local changes
1555- 3. Push first change batch
1556- Repeat if there are more local changes.
1557+ See description of _sync_project_generator().
15571558
15581559 :param project_directory: Project's directory
1559- :param upload_progress: If True, the method will be a generator yielding upload progress as (size_change, job) tuples.
15601560 """
1561- mp = MerginProject (project_directory )
1562- has_changes = True
1563- server_conflict_attempts = 0
1564- while has_changes :
1565- self .pull_project (project_directory )
1566- try :
1567- job = push_project_async (self , project_directory )
1568- if not job :
1569- break
1570- push_project_wait (job )
1571- push_project_finalize (job )
1572- _ , has_changes = get_push_changes_batch (self , mp )
1573- server_conflict_attempts = 0
1574- except ClientError as e :
1575- if e .is_retryable_sync () and server_conflict_attempts < PUSH_ATTEMPTS - 1 :
1576- # retry on conflict, e.g. when server has changes that we do not have yet
1577- mp .log .info (
1578- f"Restarting sync process (conflict on server) - { server_conflict_attempts + 1 } /{ PUSH_ATTEMPTS } "
1579- )
1580- server_conflict_attempts += 1
1581- sleep (PUSH_ATTEMPT_WAIT )
1582- continue
1583- raise e
1561+ # walk through the generator to perform the sync
1562+ # in this method we do not yield anything to the caller
1563+ for _ in self .sync_project_generator (project_directory ):
1564+ pass
0 commit comments