Perform an operation on Todoist using the API sync end-point.
8556
def _perform_command(user, command_type, command_args):
    """"""
    command_uuid = _gen_uuid()
    command = {
        'type': command_type,
        'args': command_args,
        'uuid': command_uuid,
        'temp_id': _gen_uuid()
    }
    commands = json.dumps([command])
    response = API.sync(user.api_token, user.sync_token, commands=commands)
    _fail_if_contains_errors(response, command_uuid)
    response_json = response.json()
    user.sync_token = response_json['sync_token']
396024
function() {
    var self = this
    self._shouldSyncFromOpts = true
    self.on('update', function() {
      if (self._shouldSyncFromOpts) self.trigger('sync')
      self._shouldSyncFromOpts = true
    })
  }
902581
def _sync_hooks(self, repos, asynchronous=True):
        """"""
        if not asynchronous:
            for repo_id in repos:
                try:
                    with db.session.begin_nested():
                        self.sync_repo_hook(repo_id)
                    db.session.commit()
                except RepositoryAccessError as e:
                    current_app.logger.warning(e.message, exc_info=True)
                except NoResultFound:
                    pass  # Repository not in DB yet
        else:
            # FIXME: We have to commit, in order to have all necessary data?
            db.session.commit()
            sync_hooks.delay(self.user_id, repos)
1260651
def perform_ops(self):
        
        with self.db:
            with closing(self.db.cursor()) as cursor:
                cursor.execute('BEGIN TRANSACTION')
                self._perform_ops(cursor)
1343931
def perform_action(
            self, action, machines, params, progress_title, success_title):
        """"""
        if len(machines) == 0:
            return 0
        with utils.Spinner() as context:
            return self._async_perform_action(
                context, action, list(machines), params,
                progress_title, success_title)
1125194
def perform_task(self, service, task_name, account, payload, callback=None):
        
        data = {
            'service': service,
            'action': task_name,
            'account': account,
        }
        data.update(payload)

        response = self._perform_post_request(self.submit_endpoint, data, self.token_header)

        task = Task(uuid=response['task_id'], callback=callback)
        self._pending_tasks[task.uuid] = task

        return task
186836
function execute() {
        var listeners,
            async = isAsync(bench);

        if (async) {
          // Use `getNext` as the first listener.
          bench.on('complete', getNext);
          listeners = bench.events.complete;
          listeners.splice(0, 0, listeners.pop());
        }
        // Execute method.
        result[index] = _.isFunction(bench && bench[name]) ? bench[name].apply(bench, args) : undefined;
        // If synchronous return `true` until finished.
        return !async && getNext();
      }
564214
def _insert_post_complete_tasks(context):
    """"""

    logging.debug("Context %s is complete.", context.id)

    # Async event handlers
    context.exec_event_handler('complete', transactional=True)

    # Insert cleanup tasks
    try:
        # TODO: If tracking results we may not want to auto cleanup and instead
        # wait until the results have been accessed.
        from furious.async import Async
        Async(_cleanup_markers, queue=CLEAN_QUEUE,
              args=[context.id, context.task_ids],
              task_args={'countdown': CLEAN_DELAY}).start()
    except:
        pass
1334360
def enqueue_sync(self, func, *func_args):
        '''
        
        '''
        worker = self.pick_sticky(0)  # just pick first always
        args = (func,) + func_args
        coro = worker.enqueue(enums.Task.FUNC, args)
        asyncio.ensure_future(coro)
214622
public void executeWithDelay() {
        long now = Clock.currentTimeMillis();
        if (delay + now > hardLimit) {
            scheduleNewExecution(now);
        } else if (!tryPostponeExecution()) {
            scheduleNewExecution(now);
        }
    }
509130
private Object execute(Class<?> service, Object actor, RequestDTO requestDTO) {
        return invoke(service, actor, requestDTO.getMethod(), requestDTO.getParamterTypes(),
                requestDTO.getParameters(), requestDTO.getAppId(), requestDTO.getToken());
    }
1344959
function(cb) {
		var todos = [], prevTodos;
		var model = this;

		open().then(function(db){
			var os = db.transaction(["todos"], "readwrite")
				.objectStore("todos");

			var req = os.openCursor();

			req.onsuccess = function(e){
				var cursor = e.target.result;
				if(cursor){
					todos.push(cursor.value);
					cursor.continue();
				} else {
					prevTodos = todos.slice();
					cb.call(model, todos);
					done();
				}
			};

			function done(){
				(todos || []).forEach(function(todo){
					os.put(todo);
				});
				prevTodos.forEach(function(todo){
					if(todos.indexOf(todo) === -1) {
						os["delete"](todo.text);
					}
				});
			}
		});
	  }
1346001
def handle(self, *args, **options):
		""""""
		for plan_data in Plan.api_list():
			plan = Plan.sync_from_stripe_data(plan_data)
			print("Synchronized plan {0}".format(plan.id))
24769
def sync_hooks(user_id, repositories):
    """"""
    from .api import GitHubAPI

    try:
        # Sync hooks
        gh = GitHubAPI(user_id=user_id)
        for repo_id in repositories:
            try:
                with db.session.begin_nested():
                    gh.sync_repo_hook(repo_id)
                # We commit per repository, because while the task is running
                # the user might enable/disable a hook.
                db.session.commit()
            except RepositoryAccessError as e:
                current_app.logger.warning(e.message, exc_info=True)
            except NoResultFound:
                pass  # Repository not in DB yet
    except Exception as exc:
        sync_hooks.retry(exc=exc)
703061
function sync() {
    syncDom.setAttribute('data-sync-state', 'syncing');
    var opts = {continuous: true, complete: syncError};
    db.replicate.to(remoteCouch, opts);
    db.replicate.from(remoteCouch, opts);
  }
363358
def call(self, operation, data):
        """"""
        print('API call [{0}:{1}], method - {2}, data - {3}'.format(
            self.host, self.api_key, operation, repr(data)))
706134
public void complete() {
        long seqNo = this.operation.getSequenceNumber();
        Preconditions.checkState(seqNo >= 0, "About to complete a CompletableOperation that has no sequence number.");

        this.done = true;
        if (this.successHandler != null) {
            Callbacks.invokeSafely(this.successHandler, null, cex -> log.error("Success Callback invocation failure.", cex));
        }
    }