experimental pypy compatibility (tested with PyPy 2.2.1)

This commit is contained in:
ha7ilm 2014-12-18 12:13:27 +01:00
parent 978acf8709
commit cd3ff41005
2 changed files with 25 additions and 10 deletions

View File

@ -43,7 +43,6 @@ import time
import md5 import md5
import random import random
import threading import threading
import dl
import sys import sys
import traceback import traceback
from collections import namedtuple from collections import namedtuple
@ -56,6 +55,14 @@ import uuid
import config_webrx as cfg import config_webrx as cfg
import signal import signal
#pypy compatibility
try: import dl
except: pass
try: import __pypy__
except: pass
pypy="__pypy__" in globals()
def import_all_plugins(directory): def import_all_plugins(directory):
for subdir in os.listdir(directory): for subdir in os.listdir(directory):
if os.path.isdir(directory+subdir) and not subdir[0]=="_": if os.path.isdir(directory+subdir) and not subdir[0]=="_":
@ -73,8 +80,7 @@ def handle_signal(signal, frame):
os._exit(1) #not too graceful exit os._exit(1) #not too graceful exit
def main(): def main():
global clients global clients, clients_mutex, pypy
global clients_mutex
print print
print "OpenWebRX - Open Source Web Based SDR for Everyone | for license see LICENSE file in the package" print "OpenWebRX - Open Source Web Based SDR for Everyone | for license see LICENSE file in the package"
print "_________________________________________________________________________________________________" print "_________________________________________________________________________________________________"
@ -88,6 +94,9 @@ def main():
#Load plugins #Load plugins
import_all_plugins("plugins/dsp/") import_all_plugins("plugins/dsp/")
#Pypy
if pypy: print "pypy detected (and now something completely different: a c code is expected to run at a speed of 3*10^8 m/s?)"
#Change process name to "openwebrx" (to be seen in ps) #Change process name to "openwebrx" (to be seen in ps)
try: try:
for libcpath in ["/lib/i386-linux-gnu/libc.so.6","/lib/libc.so.6"]: for libcpath in ["/lib/i386-linux-gnu/libc.so.6","/lib/libc.so.6"]:
@ -105,7 +114,8 @@ def main():
print "[openwebrx-main] Started rtl thread: "+cfg.start_rtl_command print "[openwebrx-main] Started rtl thread: "+cfg.start_rtl_command
#Run rtl_mus.py in a different OS thread #Run rtl_mus.py in a different OS thread
rtl_mus_thread=threading.Thread(target = lambda:subprocess.Popen("python2 rtl_mus.py config_rtl", shell=True), args=()) python_command="pypy" if pypy else "python2"
rtl_mus_thread=threading.Thread(target = lambda:subprocess.Popen(python_command+" rtl_mus.py config_rtl", shell=True), args=())
rtl_mus_thread.start() # The new feature in GNU Radio 3.7: top_block() locks up ALL python threads until it gets the TCP connection. rtl_mus_thread.start() # The new feature in GNU Radio 3.7: top_block() locks up ALL python threads until it gets the TCP connection.
print "[openwebrx-main] Started rtl_mus." print "[openwebrx-main] Started rtl_mus."
time.sleep(1) #wait until it really starts time.sleep(1) #wait until it really starts

View File

@ -36,8 +36,10 @@ import thread
import pdb import pdb
import asyncore import asyncore
import multiprocessing import multiprocessing
import dl
import signal import signal
#pypy compatiblity
try: import dl
except: pass
import code import code
import traceback import traceback
@ -504,11 +506,14 @@ if __name__=="__main__":
print " distributed under GNU GPL v3" print " distributed under GNU GPL v3"
print print
for libcpath in ["/lib/i386-linux-gnu/libc.so.6","/lib/libc.so.6"]: try:
if os.path.exists(libcpath): for libcpath in ["/lib/i386-linux-gnu/libc.so.6","/lib/libc.so.6"]:
libc = dl.open(libcpath) if os.path.exists(libcpath):
libc.call("prctl", 15, "rtl_mus", 0, 0, 0) libc = dl.open(libcpath)
break libc.call("prctl", 15, "rtl_mus", 0, 0, 0)
break
except:
pass
# === Load configuration script === # === Load configuration script ===
if len(sys.argv)==1: if len(sys.argv)==1: