Python google.appengine.api.taskqueue.TaskAlreadyExistsError() Examples
The following are 16
code examples of google.appengine.api.taskqueue.TaskAlreadyExistsError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
google.appengine.api.taskqueue
, or try the search function
.
Example #1
Source File: handlers.py From browserscope with Apache License 2.0 | 6 votes |
def schedule(cls, base_path, mapreduce_spec): """Schedule finalize task. Args: mapreduce_spec: mapreduce specification as MapreduceSpec. """ task_name = mapreduce_spec.mapreduce_id + "-finalize" finalize_task = taskqueue.Task( name=task_name, url=base_path + "/finalizejob_callback", params={"mapreduce_id": mapreduce_spec.mapreduce_id}) queue_name = os.environ.get("HTTP_X_APPENGINE_QUEUENAME", "default") if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_controller_task", finalize_task, queue_name): try: finalize_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r already exists. %s: %s", task_name, e.__class__, e)
Example #2
Source File: handlers.py From locality-sensitive-hashing with MIT License | 6 votes |
def schedule(cls, mapreduce_spec): """Schedule finalize task. Args: mapreduce_spec: mapreduce specification as MapreduceSpec. """ task_name = mapreduce_spec.mapreduce_id + "-finalize" finalize_task = taskqueue.Task( name=task_name, url=(mapreduce_spec.params["base_path"] + "/finalizejob_callback/" + mapreduce_spec.mapreduce_id), params={"mapreduce_id": mapreduce_spec.mapreduce_id}, headers=util._get_task_headers(mapreduce_spec.mapreduce_id)) queue_name = util.get_queue_name(None) if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_controller_task", finalize_task, queue_name): try: finalize_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r already exists. %s: %s", task_name, e.__class__, e)
Example #3
Source File: handlers.py From python-compat-runtime with Apache License 2.0 | 6 votes |
def schedule(cls, mapreduce_spec): """Schedule finalize task. Args: mapreduce_spec: mapreduce specification as MapreduceSpec. """ task_name = mapreduce_spec.mapreduce_id + "-finalize" finalize_task = taskqueue.Task( name=task_name, url=(mapreduce_spec.params["base_path"] + "/finalizejob_callback/" + mapreduce_spec.mapreduce_id), params={"mapreduce_id": mapreduce_spec.mapreduce_id}, headers=util._get_task_headers(mapreduce_spec.mapreduce_id)) queue_name = util.get_queue_name(None) if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_controller_task", finalize_task, queue_name, transactional=False): try: finalize_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r already exists. %s: %s", task_name, e.__class__, e)
Example #4
Source File: handlers.py From appengine-mapreduce with Apache License 2.0 | 6 votes |
def schedule(cls, mapreduce_spec): """Schedule finalize task. Args: mapreduce_spec: mapreduce specification as MapreduceSpec. """ task_name = mapreduce_spec.mapreduce_id + "-finalize" finalize_task = taskqueue.Task( name=task_name, url=(mapreduce_spec.params["base_path"] + "/finalizejob_callback/" + mapreduce_spec.mapreduce_id), params={"mapreduce_id": mapreduce_spec.mapreduce_id}, headers=util._get_task_headers(mapreduce_spec.mapreduce_id)) queue_name = util.get_queue_name(None) if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_controller_task", finalize_task, queue_name): try: finalize_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r already exists. %s: %s", task_name, e.__class__, e)
Example #5
Source File: handlers.py From browserscope with Apache License 2.0 | 5 votes |
def _add_task(cls, worker_task, mapreduce_spec, queue_name): """Schedule slice scanning by adding it to the task queue. Args: worker_task: a model.HugeTask task for slice. This is NOT a taskqueue task. mapreduce_spec: an instance of model.MapreduceSpec. queue_name: Optional queue to run on; uses the current queue of execution or the default queue if unspecified. """ if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_worker_task", worker_task, queue_name): try: # Not adding transactionally because worker_task has name. # Named task is not allowed for transactional add. worker_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r already exists. %s: %s", worker_task.name, e.__class__, e)
Example #6
Source File: handlers.py From browserscope with Apache License 2.0 | 5 votes |
def reschedule(cls, mapreduce_state, base_path, mapreduce_spec, serial_id, queue_name=None): """Schedule new update status callback task. Args: mapreduce_state: mapreduce state as model.MapreduceState base_path: mapreduce handlers url base path as string. mapreduce_spec: mapreduce specification as MapreduceSpec. serial_id: id of the invocation as int. queue_name: The queue to schedule this task on. Will use the current queue of execution if not supplied. """ task_name = ControllerCallbackHandler.get_task_name( mapreduce_spec, serial_id) task_params = ControllerCallbackHandler.controller_parameters( mapreduce_spec, serial_id) if not queue_name: queue_name = os.environ.get("HTTP_X_APPENGINE_QUEUENAME", "default") controller_callback_task = model.HugeTask( url=base_path + "/controller_callback", name=task_name, params=task_params, countdown=_CONTROLLER_PERIOD_SEC, parent=mapreduce_state) if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_controller_task", controller_callback_task, queue_name): try: controller_callback_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r with params %r already exists. %s: %s", task_name, task_params, e.__class__, e)
Example #7
Source File: common.py From browserscope with Apache License 2.0 | 5 votes |
def run(self, seconds=None): task = self.get_callback_task( countdown=seconds, name='ae-pipeline-delay-' + self.pipeline_id) try: task.add(self.queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError): pass
Example #8
Source File: pipeline.py From browserscope with Apache License 2.0 | 5 votes |
def post(self): if 'HTTP_X_APPENGINE_TASKNAME' not in self.request.environ: self.response.set_status(403) return context = _PipelineContext.from_environ(self.request.environ) # Set of stringified db.Keys of children to run. all_pipeline_keys = set() # For backwards compatibility with the old style of fan-out requests. all_pipeline_keys.update(self.request.get_all('pipeline_key')) # Fetch the child pipelines from the parent. This works around the 10KB # task payload limit. This get() is consistent-on-read and the fan-out # task is enqueued in the transaction that updates the parent, so the # fanned_out property is consistent here. parent_key = self.request.get('parent_key') child_indexes = [int(x) for x in self.request.get_all('child_indexes')] if parent_key: parent_key = db.Key(parent_key) parent = db.get(parent_key) for index in child_indexes: all_pipeline_keys.add(str(parent.fanned_out[index])) all_tasks = [] for pipeline_key in all_pipeline_keys: all_tasks.append(taskqueue.Task( url=context.pipeline_handler_path, params=dict(pipeline_key=pipeline_key), headers={'X-Ae-Pipeline-Key': pipeline_key}, name='ae-pipeline-fan-out-' + db.Key(pipeline_key).name())) batch_size = 100 # Limit of taskqueue API bulk add. for i in xrange(0, len(all_tasks), batch_size): batch = all_tasks[i:i+batch_size] try: taskqueue.Queue(context.queue_name).add(batch) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError): pass
Example #9
Source File: handlers.py From locality-sensitive-hashing with MIT License | 5 votes |
def _add_task(cls, worker_task, mapreduce_spec, queue_name): """Schedule slice scanning by adding it to the task queue. Args: worker_task: a model.HugeTask task for slice. This is NOT a taskqueue task. mapreduce_spec: an instance of model.MapreduceSpec. queue_name: Optional queue to run on; uses the current queue of execution or the default queue if unspecified. """ if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_worker_task", worker_task, queue_name): try: # Not adding transactionally because worker_task has name. # Named task is not allowed for transactional add. worker_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r already exists. %s: %s", worker_task.name, e.__class__, e)
Example #10
Source File: handlers.py From locality-sensitive-hashing with MIT License | 5 votes |
def reschedule(cls, mapreduce_state, mapreduce_spec, serial_id, queue_name=None): """Schedule new update status callback task. Args: mapreduce_state: mapreduce state as model.MapreduceState mapreduce_spec: mapreduce specification as MapreduceSpec. serial_id: id of the invocation as int. queue_name: The queue to schedule this task on. Will use the current queue of execution if not supplied. """ task_name = ControllerCallbackHandler.get_task_name( mapreduce_spec, serial_id) task_params = ControllerCallbackHandler.controller_parameters( mapreduce_spec, serial_id) if not queue_name: queue_name = os.environ.get("HTTP_X_APPENGINE_QUEUENAME", "default") controller_callback_task = model.HugeTask( url=(mapreduce_spec.params["base_path"] + "/controller_callback/" + mapreduce_spec.mapreduce_id), name=task_name, params=task_params, countdown=parameters.config._CONTROLLER_PERIOD_SEC, parent=mapreduce_state, headers=util._get_task_headers(mapreduce_spec.mapreduce_id)) if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_controller_task", controller_callback_task, queue_name): try: controller_callback_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r with params %r already exists. %s: %s", task_name, task_params, e.__class__, e)
Example #11
Source File: common.py From locality-sensitive-hashing with MIT License | 5 votes |
def run(self, seconds=None): task = self.get_callback_task( countdown=seconds, name='ae-pipeline-delay-' + self.pipeline_id) try: task.add(self.queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError): pass
Example #12
Source File: pipeline.py From locality-sensitive-hashing with MIT License | 5 votes |
def post(self): if 'HTTP_X_APPENGINE_TASKNAME' not in self.request.environ: self.response.set_status(403) return context = _PipelineContext.from_environ(self.request.environ) # Set of stringified db.Keys of children to run. all_pipeline_keys = set() # For backwards compatibility with the old style of fan-out requests. all_pipeline_keys.update(self.request.get_all('pipeline_key')) # Fetch the child pipelines from the parent. This works around the 10KB # task payload limit. This get() is consistent-on-read and the fan-out # task is enqueued in the transaction that updates the parent, so the # fanned_out property is consistent here. parent_key = self.request.get('parent_key') child_indexes = [int(x) for x in self.request.get_all('child_indexes')] if parent_key: parent_key = db.Key(parent_key) parent = db.get(parent_key) for index in child_indexes: all_pipeline_keys.add(str(parent.fanned_out[index])) all_tasks = [] for pipeline_key in all_pipeline_keys: all_tasks.append(taskqueue.Task( url=context.pipeline_handler_path, params=dict(pipeline_key=pipeline_key), headers={'X-Ae-Pipeline-Key': pipeline_key}, name='ae-pipeline-fan-out-' + db.Key(pipeline_key).name())) batch_size = 100 # Limit of taskqueue API bulk add. for i in xrange(0, len(all_tasks), batch_size): batch = all_tasks[i:i+batch_size] try: taskqueue.Queue(context.queue_name).add(batch) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError): pass
Example #13
Source File: handlers.py From python-compat-runtime with Apache License 2.0 | 5 votes |
def _add_task(cls, worker_task, mapreduce_spec, queue_name, transactional=False): """Schedule slice scanning by adding it to the task queue. Args: worker_task: a model.HugeTask task for slice. This is NOT a taskqueue task. mapreduce_spec: an instance of model.MapreduceSpec. queue_name: Optional queue to run on; uses the current queue of execution or the default queue if unspecified. transactional: If the task should be part of an existing transaction. """ if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_worker_task", worker_task, queue_name, transactional=transactional): try: worker_task.add(queue_name, transactional=transactional) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r already exists. %s: %s", worker_task.name, e.__class__, e)
Example #14
Source File: handlers.py From python-compat-runtime with Apache License 2.0 | 5 votes |
def reschedule(cls, mapreduce_state, mapreduce_spec, serial_id, queue_name=None): """Schedule new update status callback task. Args: mapreduce_state: mapreduce state as model.MapreduceState mapreduce_spec: mapreduce specification as MapreduceSpec. serial_id: id of the invocation as int. queue_name: The queue to schedule this task on. Will use the current queue of execution if not supplied. """ task_name = ControllerCallbackHandler.get_task_name( mapreduce_spec, serial_id) task_params = ControllerCallbackHandler.controller_parameters( mapreduce_spec, serial_id) if not queue_name: queue_name = os.environ.get("HTTP_X_APPENGINE_QUEUENAME", "default") controller_callback_task = model.HugeTask( url=(mapreduce_spec.params["base_path"] + "/controller_callback/" + mapreduce_spec.mapreduce_id), name=task_name, params=task_params, countdown=parameters.config._CONTROLLER_PERIOD_SEC, parent=mapreduce_state, headers=util._get_task_headers(mapreduce_spec.mapreduce_id)) if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_controller_task", controller_callback_task, queue_name, transactional=False): try: controller_callback_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r with params %r already exists. %s: %s", task_name, task_params, e.__class__, e)
Example #15
Source File: handlers.py From appengine-mapreduce with Apache License 2.0 | 5 votes |
def _add_task(cls, worker_task, mapreduce_spec, queue_name): """Schedule slice scanning by adding it to the task queue. Args: worker_task: a model.HugeTask task for slice. This is NOT a taskqueue task. mapreduce_spec: an instance of model.MapreduceSpec. queue_name: Optional queue to run on; uses the current queue of execution or the default queue if unspecified. """ if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_worker_task", worker_task, queue_name): try: # Not adding transactionally because worker_task has name. # Named task is not allowed for transactional add. worker_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r already exists. %s: %s", worker_task.name, e.__class__, e)
Example #16
Source File: handlers.py From appengine-mapreduce with Apache License 2.0 | 5 votes |
def reschedule(cls, mapreduce_state, mapreduce_spec, serial_id, queue_name=None): """Schedule new update status callback task. Args: mapreduce_state: mapreduce state as model.MapreduceState mapreduce_spec: mapreduce specification as MapreduceSpec. serial_id: id of the invocation as int. queue_name: The queue to schedule this task on. Will use the current queue of execution if not supplied. """ task_name = ControllerCallbackHandler.get_task_name( mapreduce_spec, serial_id) task_params = ControllerCallbackHandler.controller_parameters( mapreduce_spec, serial_id) if not queue_name: queue_name = os.environ.get("HTTP_X_APPENGINE_QUEUENAME", "default") controller_callback_task = model.HugeTask( url=(mapreduce_spec.params["base_path"] + "/controller_callback/" + mapreduce_spec.mapreduce_id), name=task_name, params=task_params, countdown=parameters.config._CONTROLLER_PERIOD_SEC, parent=mapreduce_state, headers=util._get_task_headers(mapreduce_spec.mapreduce_id)) if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_controller_task", controller_callback_task, queue_name): try: controller_callback_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r with params %r already exists. %s: %s", task_name, task_params, e.__class__, e)