WebFaction
Community site: login faq

Hi, I'm running a django web application witch launch a java compilation command and I need to catch the javac stderr, I've put it in a separate task (Celery), here is the code:

class JavaSubTask(Task):

   def run(self, filepath, **kwargs):     
      p = subprocess.Popen([/usr/bin/javac',filepath], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
      p.wait()
      command_output, err = p.communicate()
      return(command_output + err)
tasks.register(JavaSubTask)

and this is how I call the task :

def compile(request):
   .........
   res=JavaSubTask.delay(filepath).get()
   .........
   return HttpResponse(res)

The problem is that the task is always returning an empty string, but when I try any other command like "ls -l", or when I give a wrong .java file path to javac it return the result or the error successfully .

I thing it have something to do with the messaging queue, maybe an incomplete configuration, here is my settings.py anyway:

import djcelery
djcelery.setup_loader()
DEBUG = True
TEMPLATE_DEBUG = DEBUG
BROKER_BACKEND = "redis"
BROKER_HOST = "localhost"
BROKER_PORT = 6379
BROKER_VHOST = "0"
BROKER_TRANSPORT ="redis"
CELERY_RESULT_BACKEND = "redis"
CELERY_REDIS_HOST = "localhost"
CELERY_REDIS_PORT = 6379
CELERY_REDIS_DB = "1"
.....
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'piston',
    'djcelery',
)

......

I'm using ubuntu server 10.04 (cant run newer because I'm on a cloud environment it's the only img available) Celery v2.4.6 Redis v2.4.18 Django v1.4.1 Webserver apache2 with mod wsgi

asked 04 Apr '13, 11:27

kain
111
accept rate: 0%


Since it is not one of our servers we can't really say what it might be. It literally could be anything. Ask the developers of the software directly or the support staff for your cloud host.

permanent link

answered 04 Apr '13, 19:20

johns
5.4k312
accept rate: 23%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×225
×21
×12
×2

question asked: 04 Apr '13, 11:27

question was seen: 3,209 times

last updated: 04 Apr '13, 19:20

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM