Hi folks,
here is a dump of my notes based on the magnificent HCI class held at:
https://www.coursera.org/course/hci
These notes include a recommended reading list + the essential points of each lecture.
ProgrammingError: execute cannot be used while an asynchronous query is underway DatabaseError: execute cannot be used while an asynchronous query is underwayAfter getting the following versions:
Django 1.4 b1 Gunicorn 0.14 Gevent 0.13.6 psycopg2 2.4.4And greening psycopg2 pre_fork like this (in the Gunicorn config):
worker_class = "gevent" def def_pre_fork(server, worker): from psyco_gevent import make_psycopg_green make_psycopg_green() worker.log.info("Made Psycopg Green") pre_fork = def_pre_forkAnd using the gunicorn_django in a virtualenv to run the server from supervisor (instead of the manage.py shortcut):
[program:photobooks] command=/path/bin/gunicorn_django -c /path/conf/photobooks_gunicorn.conf.py directory=/path/src/photobooks environment=PATH="/path/bin"I was not able to reproduce the problem any more.
from celery.utils import uuid from celery.task.chords import Chord class progress_chord(object): Chord = Chord def __init__(self, tasks, **options): self.tasks = tasks self.options = options def __call__(self, body, **options): tid = body.options.setdefault("task_id", uuid()) r = self.Chord.apply_async((list(self.tasks), body), self.options, **options) return body.type.app.AsyncResult(tid), r
result_chord, result_set = tasks.progress_chord(taskSet)(syncTask.subtask(params))
def check_batch_result(request): chord_result = AsyncResult(request.GET.get("chord_task_id","")) task_set_result = AsyncResult(request.GET.get("set_task_id","")).result response = {} response["tasks_completed"] = task_set_result.completed_count() response["tasks_total"] = len(task_set_result.results) if chord_result.state == celery.states.PENDING: response["status"] = "pending" elif chord_result.state == celery.states.STARTED: response["status"] = "started" elif chord_result.state == celery.states.RETRY: response["status"] = "retry" elif chord_result.state == celery.states.RETRY: response["status"] = "failure" elif chord_result.state == celery.states.SUCCESS: response["status"] = "successful" response["result"] = chord_result.result return Structure2JsonResponse(response)