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 random
import threading
import dl
import sys
import traceback
from collections import namedtuple
@ -56,6 +55,14 @@ import uuid
import config_webrx as cfg
import signal
#pypy compatibility
try: import dl
except: pass
try: import __pypy__
except: pass
pypy="__pypy__" in globals()
def import_all_plugins(directory):
for subdir in os.listdir(directory):
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
def main():
global clients
global clients_mutex
global clients, clients_mutex, pypy
print
print "OpenWebRX - Open Source Web Based SDR for Everyone | for license see LICENSE file in the package"
print "_________________________________________________________________________________________________"
@ -88,6 +94,9 @@ def main():
#Load plugins
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)
try:
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
#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.
print "[openwebrx-main] Started rtl_mus."
time.sleep(1) #wait until it really starts

View File

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