Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: nonami Newsgroups: comp.lang.python Subject: Problems using celery and pyelasticsearch Date: Mon, 7 Dec 2015 02:37:15 +0100 Lines: 73 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de PrgPf7G4GF5uyeeKNewuDgyytfOyDQA47mEW7re42Yig== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'elif': 0.04; 'none:': 0.05; 'stops': 0.07; 'subject:using': 0.09; 'exception': 0.13; 'output': 0.13; 'def': 0.13; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:q 30': 0.16; 'subject:Problems': 0.16; 'debugging': 0.18; 'skip:{ 20': 0.18; 'try:': 0.18; 'tests': 0.18; 'exceptions': 0.22; 'header:User- Agent:1': 0.26; 'executing': 0.27; 'skip:e 30': 0.27; 'function': 0.28; 'idea': 0.28; "skip:' 10": 0.28; 'inspect': 0.29; 'received:192.168.10': 0.29; 'skip:q 20': 0.29; 'raise': 0.29; 'task': 0.30; 'anyone': 0.32; 'useful': 0.33; 'skip:j 20': 0.33; 'message-id:@gmail.com': 0.34; 'except': 0.34; 'running': 0.34; 'info': 0.34; 'received:google.com': 0.35; 'skip:c 30': 0.35; 'could': 0.35; 'subject:skip:p 10': 0.35; 'tasks': 0.35; 'received:74.125.82': 0.35; 'problem.': 0.35; 'sometimes': 0.35; 'but': 0.36; 'skip:{ 10': 0.36; 'to:addr:python-list': 0.36; 'thanks': 0.37; 'hi,': 0.38; 'does': 0.39; 'received:192': 0.39; 'skip:e 20': 0.39; 'to:addr:python.org': 0.40; 'hang': 0.60; 'further': 0.62; 'tasks.': 0.66; 'here': 0.66; 'jobs': 0.67; 'received:74.125.82.41': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version :content-type:content-transfer-encoding; bh=KjLL4HkSM6dD05vtmLVEmKD+1dv8tJbPSROgWkRa+EA=; b=HFunFomRYRlIm5HsfS8SwckopmNObtNuPKvauYQvyLirDgwxKWSDIKwkQjy4nAVvsG bpeDtZmoDHqU8ueqrjB5EdGGFnUbxB+LX4XCeB+Sq6oYrFX60HfWL1MAmif5Mmftm6S9 9JQqhXNsXwhAwf5oX2EpDxnq4abSHfkQ5lkOo0wHjv/ks/adBNBeImCOIvwk9x0zAInY xzJDAhsVVOEp07TtdWloUQdPiavBpFJIKpTJk/pQIUVFZWGFjxW/ye+2MWpPWR6oMUXk 8ItxuXCBTp4qHETBUFF9ZfhXfjhxWL0wryakWXpsJd3HDhdFn97Kcy3Yxzsr8/N33JMy 79ig== X-Received: by 10.28.103.9 with SMTP id b9mr17298885wmc.8.1449452238168; Sun, 06 Dec 2015 17:37:18 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100076 Hi, I create a task that uses this function def get_jobs(specialization, yoe): try: key = "SpecAlert-" if len(specialization): key += '-'.join(map(str, specialization)) if yoe is not None: key += '-yoe'.join(yoe) jobs = memcache_client.get(key) if not jobs: spec_param = {'terms': {'jobs.specialization.id': specialization}} if yoe is not None: if len(yoe) == 2: yoe_param = {'range': {'jobs.experience': {'gte': yoe[0], 'lte': yoe[1]}}} elif int(yoe[0]): yoe_param = {'range': {'jobs.experience': {'gte': yoe[0]}}} else: yoe_param = {'term': {'jobs.experience': yoe[0]}} query_bool = {'must': [{'range': {'jobs.deadline': {'gt': str(date.today() + timedelta(days=1))}}}]} query_bool['must_not'] = [{'term': {'jobs.job_level': JOB_LEVEL_VOC}}] if specialization: query_bool['must'].append(spec_param) if yoe: query_bool['must'].append(yoe_param) es = config.get_es_connection() es_config = config.config['elasticsearch'] # print({'query': {'bool': query_bool}}) try: # Tasks sometimes hang here result = es.search(index=es_config['job_index'], doc_type=es_config['job_type'], body={'query': {'bool': query_bool}}) jobs = [] for j in result['hits']['hits']: jobs.append(j['_source']) except ElasticsearchException as esc: print(esc) jobs = [] if jobs: memcache_client.set(key, jobs, 3600) except Exception as e: jobs = [] print(e) return jobs I find that the celery worker often stops executing tasks. After tests and debugging I in that this NEVER happens when I take out this line(s): result = es.search(index=es_config['job_index'], doc_type=es_config['job_type'], body={'query': {'bool': query_bool}}) This line also does not raise any Exceptions Does anyone have any idea what could be going on or how I can further inspect running tasks. N.B celery worker is started with loglevel=debug flag but does not output any useful info as regards the problem. Thanks