Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launching an Android Emulator from Python-Django

def start_test(request):
    os.system('echo Starting emulator...')
    os.system('./android-sdk-linux_x86/tools/emulator -avd testavd &')
    return HttpResponse("OK")

Here is the barebones code of what I am trying to do.
When this code gets executed, the server stops responding while running the emulator. Any help appreciated.
I am using the django development server. Here is the server output:

Django version 1.1.1, using settings 'Cloust.settings'
Development server is running at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
Starting emulator...
[21/Apr/2011 02:00:06] "GET /start_test/a.apk/ HTTP/1.1" 200 5
emulator: warning: opening audio output failed

emulator: emulator window was out of view and was recentred
like image 810
Mark Avatar asked Oct 11 '22 05:10

Mark


2 Answers

Maybe you should try to run emulator in separate thread?

E.g.

import subprocess
thread = threading.Thread(target=subprocess.popen(['./android-sdk-linux_x86/tools/emulator', '-avd', 'testavd', '&'])
thread.start()
like image 170
Roman Bodnarchuk Avatar answered Oct 20 '22 06:10

Roman Bodnarchuk


Considering you are using django you will probably need to manage the emulators somehow. Threading is not really a good option in this case I think.

I'd suggest looking into task management in this case with something like http://code.google.com/p/django-tasks/

like image 29
Keith Avatar answered Oct 20 '22 04:10

Keith