Exemplo n.º 1
0
def sync_evernote(integration):
    """
    Sync evernote project with Todoist

    The function asks for new changes in Evernote account and generates
    `evernote_note_changed` and `evernote_note_deleted` events (handled in
    signals.py). It keeps the "last sync" state in the EvernoteSyncState object
    """
    lock_key = 'utils-sync-evernote-%s' % integration.id
    lock_timeout = 5 * 60
    blocking_timeout = 60

    with get_redis().lock(lock_key,
                          timeout=lock_timeout,
                          blocking_timeout=blocking_timeout):
        local_sync_state, _ = EvernoteSyncState.objects.get_or_create(
            integration=integration)

        last_update_count, last_sync_time = _do_sync(
            integration, local_sync_state.last_update_count,
            local_sync_state.last_sync_time)

        local_sync_state.last_update_count = last_update_count
        local_sync_state.last_sync_time = last_sync_time
        local_sync_state.save()
Exemplo n.º 2
0
 def lock_and_ctx(self):
     """
     Internal function returning a "global redis lock" to make sure we
     perform only one sync operation at a time.
     """
     lock_name = 'sync-bridge-%s-%s' % (self.integration.id, self.name)
     lock_timeout = 60 * 5  # no more than 5 mins per sync operation
     blocking_timeout = 30  # no more than 30 seconds waiting for the lock
     with ctx(integration=self.integration, user=self.integration.user):
         return get_redis().lock(lock_name, timeout=lock_timeout,
                                 blocking_timeout=blocking_timeout)
Exemplo n.º 3
0
 def lock_and_ctx(self):
     """
     Internal function returning a "global redis lock" to make sure we
     perform only one sync operation at a time.
     """
     lock_name = 'sync-bridge-%s-%s' % (self.integration.id, self.name)
     lock_timeout = 60 * 5  # no more than 5 mins per sync operation
     blocking_timeout = 30  # no more than 30 seconds waiting for the lock
     with ctx(integration=self.integration, user=self.integration.user):
         return get_redis().lock(lock_name,
                                 timeout=lock_timeout,
                                 blocking_timeout=blocking_timeout)
Exemplo n.º 4
0
def sync_evernote(integration):
    """
    Sync evernote project with Todoist

    The function asks for new changes in Evernote account and generates
    `evernote_note_changed` and `evernote_note_deleted` events (handled in
    signals.py). It keeps the "last sync" state in the EvernoteSyncState object
    """
    lock_key = 'utils-sync-evernote-%s' % integration.id
    lock_timeout = 5 * 60
    blocking_timeout = 60

    with get_redis().lock(lock_key, timeout=lock_timeout,
                          blocking_timeout=blocking_timeout):
        local_sync_state, _ = EvernoteSyncState.objects.get_or_create(integration=integration)

        last_update_count, last_sync_time = _do_sync(integration,
                                                     local_sync_state.last_update_count,
                                                     local_sync_state.last_sync_time)

        local_sync_state.last_update_count = last_update_count
        local_sync_state.last_sync_time = last_sync_time
        local_sync_state.save()