Tidy with flake8

This commit is contained in:
Curtis
2015-04-11 22:50:11 +10:00
parent f6e5db93d8
commit 057cfe761f
211 changed files with 1622 additions and 1311 deletions
+1
View File
@@ -15,6 +15,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
CARBON_SERVER = "127.0.0.1:2003"
def update_carbon(signum):
# connect to the carbon server
carbon_fd = uwsgi.connect(CARBON_SERVER)
+6 -3
View File
@@ -12,13 +12,15 @@ import greenlet
uwsgi_pypy_greenlets = {}
def uwsgi_pypy_greenlet_wrapper():
lib.async_schedule_to_req_green()
@ffi.callback("void()")
def uwsgi_pypy_greenlet_schedule():
id = lib.uwsgi.wsgi_req.async_id
modifier1 = lib.uwsgi.wsgi_req.uh.modifier1;
modifier1 = lib.uwsgi.wsgi_req.uh.modifier1
# generate a new greenlet
if not lib.uwsgi.wsgi_req.suspended:
@@ -36,10 +38,11 @@ def uwsgi_pypy_greenlet_schedule():
if lib.uwsgi.p[modifier1].resume:
lib.uwsgi.p[modifier1].resume(ffi.NULL)
@ffi.callback("void(struct wsgi_request *)")
def uwsgi_pypy_greenlet_switch(wsgi_req):
id = wsgi_req.async_id
modifier1 = wsgi_req.uh.modifier1;
wsgi_req.async_id
modifier1 = wsgi_req.uh.modifier1
# this is called in the current greenlet
if lib.uwsgi.p[modifier1].suspend:
+1 -1
View File
@@ -11,7 +11,7 @@ uwsgi_args = []
for arg in sys.argv[2:]:
uwsgi_args.append(arg)
#pyuwsgi.run('welcome.ini')
# pyuwsgi.run('welcome.ini')
pyuwsgi.run(uwsgi_args)
# if you are here uWSGI has been reloaded
+3 -2
View File
@@ -4,6 +4,7 @@ from django.conf import settings
import os
import sys
class Command(BaseCommand):
help = "Runs this project as a uWSGI application. Requires the uwsgi binary in system path."
@@ -12,10 +13,10 @@ class Command(BaseCommand):
def handle(self, *args, **options):
for arg in args:
k,v = arg.split('=')
k, v = arg.split('=')
if k == 'http':
if self.http_port:
self.http_port = v
self.http_port = v
elif k == 'socket':
self.http_port = None
self.socket_addr = v
+2 -3
View File
@@ -1,11 +1,10 @@
from tasksconsumer import enqueue
def application(env, sr):
sr('200 OK', [('Content-Type','text/html')])
sr('200 OK', [('Content-Type', 'text/html')])
enqueue(queue='fast', pippo='pluto')
return "Task enqueued"
+3 -1
View File
@@ -1,9 +1,11 @@
from tasksconsumer import *
from tasksconsumer import queueconsumer
@queueconsumer('fast', 4)
def fast_queue(arguments):
print "fast", arguments
@queueconsumer('slow')
def slow_queue(arguments):
print "foobar", arguments
+15 -14
View File
@@ -1,35 +1,36 @@
from uwsgidecorators import *
from uwsgidecorators import spool
import Queue
from threading import Thread
queues = {}
class queueconsumer(object):
def __init__(self, name, num=1, **kwargs):
self.name = name
self.num = num
self.num = num
self.queue = Queue.Queue()
self.threads = []
self.func = None
queues[self.name] = self
self.threads = []
self.func = None
queues[self.name] = self
@staticmethod
def consumer(self):
while True:
req = self.queue.get()
req = self.queue.get()
print req
self.func(req)
self.queue.task_done()
self.func(req)
self.queue.task_done()
def __call__(self, f):
self.func = f
for i in range(self.num):
t = Thread(target=self.consumer,args=(self,))
self.threads.append(t)
t.daemon = True
t.start()
for i in range(self.num):
t = Thread(target=self.consumer, args=(self,))
self.threads.append(t)
t.daemon = True
t.start()
@spool
def spooler_enqueuer(arguments):
+26 -27
View File
@@ -1,22 +1,22 @@
from twisted.internet import defer, protocol, reactor
from twisted.protocols import basic
from twisted.web2 import server, http, resource, responsecode, stream, channel
from twisted.application import service, strports
from twisted.web2 import http, resource, responsecode, stream
import struct
class uWSGIClientResource(resource.LeafResource):
def __init__(self,app='', port=3030, host='localhost'):
def __init__(self, app='', port=3030, host='localhost'):
resource.LeafResource.__init__(self)
self.host = host
self.port = port
self.app = app
def renderHTTP(self, request):
return uWSGI(request, self.app, self.host, self.port)
def uWSGI(request, app, host, port):
if request.stream.length is None:
return http.Response(responsecode.LENGTH_REQUIRED)
@@ -25,9 +25,10 @@ def uWSGI(request, app, host, port):
factory = uWSGIClientProtocolFactory(request)
reactor.connectTCP(host, port, factory)
return factory.deferred
class uWSGIClientProtocol(basic.LineReceiver):
def __init__(self, request, deferred):
self.request = request
self.deferred = deferred
@@ -35,8 +36,8 @@ class uWSGIClientProtocol(basic.LineReceiver):
self.response = http.Response(stream=self.stream)
self.status_parsed = None
def build_uwsgi_var(self,key,value):
return struct.pack('<H',len(key)) + key + struct.pack('<H',len(value)) + value
def build_uwsgi_var(self, key, value):
return struct.pack('<H', len(key)) + key + struct.pack('<H', len(value)) + value
def connectionMade(self):
print(self.request.__dict__)
@@ -46,15 +47,14 @@ class uWSGIClientProtocol(basic.LineReceiver):
vars = ''
if self.request.stream.length:
vars += self.build_uwsgi_var('CONTENT_LENGTH',str(self.request.stream.length))
vars += self.build_uwsgi_var('CONTENT_LENGTH', str(self.request.stream.length))
for hkey, hval in self.request.headers.getAllRawHeaders():
# use a list, probably it will be extended
if hkey.lower() not in ('content-type'):
vars += self.build_uwsgi_var('HTTP_'+hkey.upper().replace('-','_'),','.join(hval))
vars += self.build_uwsgi_var('HTTP_' + hkey.upper().replace('-', '_'), ','.join(hval))
else:
vars += self.build_uwsgi_var(hkey.upper().replace('-','_'),','.join(hval))
vars += self.build_uwsgi_var(hkey.upper().replace('-', '_'), ','.join(hval))
vars += self.build_uwsgi_var('REQUEST_METHOD', self.request.method)
vars += self.build_uwsgi_var('SCRIPT_NAME', self.request.uwsgi_app)
@@ -62,21 +62,20 @@ class uWSGIClientProtocol(basic.LineReceiver):
vars += self.build_uwsgi_var('QUERY_STRING', self.request.querystring)
vars += self.build_uwsgi_var('SERVER_NAME', self.request.host)
vars += self.build_uwsgi_var('SERVER_PORT', str(self.request.port))
vars += self.build_uwsgi_var('SERVER_PROTOCOL', self.request.scheme.upper()+'/'+str(self.request.clientproto[0]) +'.'+str(self.request.clientproto[1]))
vars += self.build_uwsgi_var('SERVER_PROTOCOL', self.request.scheme.upper() + '/' + str(self.request.clientproto[0]) + '.' + str(self.request.clientproto[1]))
vars += self.build_uwsgi_var('REQUEST_URI', self.request.uri)
vars += self.build_uwsgi_var('REMOTE_ADDR', self.request.remoteAddr.host)
self.transport.write(struct.pack('<BHB',0, len(vars),0))
self.transport.write(struct.pack('<BHB', 0, len(vars), 0))
self.transport.write(vars)
# send request data
stream.StreamProducer(self.request.stream).beginProducing(self.transport)
def lineReceived(self, line):
if self.status_parsed is None:
self.response.code = line.split(' ',2)[1]
self.response.code = line.split(' ', 2)[1]
self.status_parsed = True
return
@@ -87,33 +86,33 @@ class uWSGIClientProtocol(basic.LineReceiver):
self.response = None
return
name, value = line.split(':',1)
name, value = line.split(':', 1)
value = value.strip()
self.response.headers.addRawHeader(name, value)
def rawDataReceived(self, data):
self.stream.write(data)
def connectionLost(self, reason):
self.stream.finish()
class uWSGIClientProtocolFactory(protocol.ClientFactory):
protocol = uWSGIClientProtocol
noisy = False # Make Factory shut up
noisy = False # Make Factory shut up
def __init__(self, request):
self.request = request
self.deferred = defer.Deferred()
def buildProtocol(self, addr):
return self.protocol(self.request, self.deferred)
def clientConnectionFailed(self, connector, reason):
self.sendFailureResponse(reason)
def sendFailureResponse(self, reason):
response = http.Response(code=responsecode.BAD_GATEWAY, stream=str(reason.value))
self.deferred.callback(response)
+46 -24
View File
@@ -6,6 +6,7 @@ import time
import sys
from optparse import OptionParser
class Cache:
def __init__(self, filename, cache_slots, block_size=65536, sample_sleep=1):
@@ -41,7 +42,7 @@ class Cache:
fields = struct.unpack_from('@HHIQQQQQ2048c', buf)
key = array.array('c', fields[8:self.key_size+8]).tostring().rstrip('\x00')
if [x for x in key if x!= '\x00']:
if [x for x in key if x != '\x00']:
buf = self.store_read_item_block(position)
value = array.array('c', buf).tostring().rstrip('\x00')
else:
@@ -55,7 +56,7 @@ class Cache:
if self.sample_sleep:
time.sleep(self.sample_sleep)
return data
def update_stats(self, data):
# data is a list of (position, key, value, len(value)) tuples
items = len([1 for x in data if x[3] > 0])
@@ -68,54 +69,75 @@ class Cache:
self.samples += 1
block_sizes = sum([x[3] for x in data])
self.block_sizes += block_sizes
self.history.append({'full': full, 'empty': empty, 'data': data, \
'items': items, 'block_sizes': block_sizes})
self.history.append({
'full': full,
'empty': empty,
'data': data,
'items': items,
'block_sizes': block_sizes
})
def dump(self):
return {
'samples': self.samples,
'history': self.history,
'cache_slots': self.cache_slots,
'sample_sleep': self.sample_sleep,
'sample_sleep': self.sample_sleep,
'cache_empty': self.cache_empty,
'cache_full': self.cache_full,
'cache_items': self.cache_items,
'block_sizes': self.block_sizes,
}
}
def show_dump(self):
d = self.dump()
print()
print("Recorded %d samples (%d second(s) sleep between samples)" % \
(d['samples'], d['sample_sleep']))
print("Cache empty %d times, full %d times, %.2f items on average" % \
(d['cache_empty'], d['cache_full'], d['cache_items'] / d['samples']))
print("Block size average size: %d bytes" % \
(d['block_sizes'] / d['cache_items'] * 8))
print("Data in cache average: %d bytes" % \
(d['block_sizes'] / d['samples'] * 8))
print("Recorded %d samples (%d second(s) sleep between samples)" % (
d['samples'],
d['sample_sleep']
))
print("Cache empty %d times, full %d times, %.2f items on average" % (
d['cache_empty'],
d['cache_full'],
d['cache_items'] / d['samples']
))
print("Block size average size: %d bytes" % (
d['block_sizes'] / d['cache_items'] * 8
))
print("Data in cache average: %d bytes" % (
d['block_sizes'] / d['samples'] * 8
))
def main(options):
cache = Cache(options.cache_store, options.cache_slots, options.block_size,
options.sleep_time)
options.sleep_time)
print("Recording...")
while True:
try:
data = cache.read()
cache.read()
except KeyboardInterrupt:
cache.show_dump()
sys.exit(0)
if __name__ == '__main__':
parser = OptionParser()
parser.add_option("-s", "--cache-slots", dest="cache_slots", type="int",
help="Slots available in the cache, uwsgi cache option")
parser.add_option("-c", "--cache-store", dest="cache_store", default="uwsgi.cache",
help="The filename of the cache store, uwsgi cache-store option. Default: uwsgi.cache")
parser.add_option("-b", "--block-size", dest="block_size", default=65536, type="int",
help="The size of the cache block, uwsgi cache-blocksize option. Default: 65536")
parser.add_option("-t", "--sleep-time", dest="sleep_time", default=1, type="int",
help="The time to sleep between each sample. Default: 1")
parser.add_option(
"-s", "--cache-slots", dest="cache_slots", type="int",
help="Slots available in the cache, uwsgi cache option"
)
parser.add_option(
"-c", "--cache-store", dest="cache_store", default="uwsgi.cache",
help="The filename of the cache store, uwsgi cache-store option. Default: uwsgi.cache"
)
parser.add_option(
"-b", "--block-size", dest="block_size", default=65536, type="int",
help="The size of the cache block, uwsgi cache-blocksize option. Default: 65536"
)
parser.add_option(
"-t", "--sleep-time", dest="sleep_time", default=1, type="int",
help="The time to sleep between each sample. Default: 1"
)
(options, args) = parser.parse_args()
if not options.cache_slots:
+2
View File
@@ -2,10 +2,12 @@ from flask import Flask, request
app = Flask(__name__)
app.debug = True
@app.route('/')
def hello_world():
return "<form method='POST' enctype='multipart/form-data' action='/upload'><input type='text' name='pippo'/><input type='file' name='ufile'/><input type='submit' value='upload'/></form>"
@app.route('/upload', methods=['GET', 'POST'])
def upload_file():
return str(len(request.form.get('pippo', 'boh'))) + request.form.get('pippo', 'boh')
+7 -1
View File
@@ -3,12 +3,18 @@ import werkzeug.testapp
uwsgi.cache_set("/cache/get", "HTTP 1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<h1>I am the uWSGI cache</h1>")
def app001(env, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return "PATH_INFO=%s" % env['PATH_INFO']
def app002(env, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return "requests: %d" % uwsgi.total_requests()
uwsgi.applications = { '':werkzeug.testapp.test_app, '/app001':app001, '/app002':app002 }
uwsgi.applications = {
'': werkzeug.testapp.test_app,
'/app001': app001,
'/app002': app002
}
+16 -18
View File
@@ -1,25 +1,23 @@
import uwsgi
import os
def application(env, start_response):
boundary = 'uwsgi_mjpeg_frame'
boundary = 'uwsgi_mjpeg_frame'
start_response('200 Ok', [
start_response('200 Ok', [
('Cache-Control', 'no-cache'),
('Cache-Control', 'private'),
('Pragma', 'no-cache'),
('Content-Type', 'multipart/x-mixed-replace; boundary=' + boundary),
])
('Cache-Control', 'no-cache'),
('Cache-Control', 'private'),
('Pragma', 'no-cache'),
('Content-Type', 'multipart/x-mixed-replace; boundary=' + boundary),
]
)
yield "--%s\r\n" % boundary
yield "--%s\r\n" % boundary
while 1:
yield "Content-Type: image/jpeg\r\n\r\n"
print os.system('screencapture -t jpg -m -T 1 screenshot.jpg')
f = open('screenshot.jpg')
yield env['wsgi.file_wrapper'](f)
yield "\r\n--%s\r\n" % boundary
#os.system('./isightcapture -w 640 -h 480 screenshot.jpg')
while 1:
yield "Content-Type: image/jpeg\r\n\r\n"
print os.system('screencapture -t jpg -m -T 1 screenshot.jpg')
f = open('screenshot.jpg')
yield env['wsgi.file_wrapper'](f)
yield "\r\n--%s\r\n" % boundary
# os.system('./isightcapture -w 640 -h 480 screenshot.jpg')
+15 -7
View File
@@ -1,22 +1,30 @@
import werkzeug
import uwsgi
def zero_app(e,s):
s('200 OK', [ ('Content-Type', 'text/plain') ])
def zero_app(e, s):
s('200 OK', [('Content-Type', 'text/plain')])
return "0"
def not_found(e,s):
s('404 Not Found', [ ('Content-Type', 'text/plain') ])
def not_found(e, s):
s('404 Not Found', [('Content-Type', 'text/plain')])
return ""
def wsgi_app(e, s):
s('200 OK', [ ('Content-Type', 'text/plain') ])
s('200 OK', [('Content-Type', 'text/plain')])
yield "I am a WSGI app\n"
def internal_server_error(e, s):
s('500 Internal Server Error', [ ('Content-Type', 'text/plain') ])
s('500 Internal Server Error', [('Content-Type', 'text/plain')])
return ""
uwsgi.applications = {'/wsgi':wsgi_app, '/test':werkzeug.test_app, '/zero':zero_app, '/notfound':not_found, '/ise':internal_server_error}
uwsgi.applications = {
'/wsgi': wsgi_app,
'/test': werkzeug.test_app,
'/zero': zero_app,
'/notfound': not_found,
'/ise': internal_server_error
}
+4 -4
View File
@@ -3,9 +3,11 @@ import os
print("!!! uWSGI version:", uwsgi.version)
def ciao():
print("modifica su /tmp")
def ciao2():
print("nuovo uwsgi_server")
print os.getpid()
@@ -23,17 +25,15 @@ counter = 0
uwsgi.post_fork_hook = ciao2
def application(env, start_response):
def application(env, start_response):
global counter
#print(env)
start_response('200 Ok', [('Content-type', 'text/plain')])
yield "hello world"
yield "hello world2"
for i in range(1,1000):
for i in range(1, 1000):
yield str(i)
yield "\n"
+3 -3
View File
@@ -1,9 +1,9 @@
def mygen(uri):
for i in xrange(1,100):
for i in xrange(1, 100):
yield "ciao %s<br/>" % uri
def application(env, start_response = None):
def application(env, start_response=None):
return '200 OK', [('Content-Type', 'text/html')], "<h1>This is the fastest homepage of the world !!!</h1>"
#return '200 OK', [('Content-Type', 'text/html')], mygen(env['PATH_INFO'])
# return '200 OK', [('Content-Type', 'text/html')], mygen(env['PATH_INFO'])
+2 -1
View File
@@ -1,6 +1,7 @@
import uwsgi
def print_logs(ip, port, message):
print(ip, port, message)
print(ip, port, message)
uwsgi.udp_callable = print_logs
+3 -2
View File
@@ -4,10 +4,11 @@ from os import path
uwsgi.snmp_set_counter64(1, 0) # Number of requests
uwsgi.snmp_set_counter64(2, 0) # Number of bytes
def application(environ, start_response):
size = path.getsize('logo_uWSGI.png')
start_response('200 OK', [('Content-Type', 'image/png'), ('Content-Length', str(size))] )
fd = open('logo_uWSGI.png','r')
start_response('200 OK', [('Content-Type', 'image/png'), ('Content-Length', str(size))])
fd = open('logo_uWSGI.png', 'r')
uwsgi.snmp_incr_counter64(1)
uwsgi.snmp_incr_counter64(2, size)
return environ['wsgi.file_wrapper'](fd, 4096)
+5 -4
View File
@@ -4,22 +4,24 @@ import uwsgi
CONSUMERS = 4
def consumer(q):
while True:
item = q.get()
print(item)
#... DO A HEAVY TASK HERE ...
# ... DO A HEAVY TASK HERE ...
q.task_done()
def spawn_consumers():
global q
q = Queue.Queue()
for i in range(CONSUMERS):
t = Thread(target=consumer,args=(q,))
t = Thread(target=consumer, args=(q,))
t.daemon = True
t.start()
print("consumer %d on worker %d started" % (i, uwsgi.worker_id()))
uwsgi.post_fork_hook = spawn_consumers
@@ -33,4 +35,3 @@ def application(env, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
yield "Task enqueued"
+60 -62
View File
@@ -1,78 +1,76 @@
import uwsgi
def application(env, start_response):
# open the socket
fd = uwsgi.async_connect("192.168.173.100:3032")
# open the socket
fd = uwsgi.async_connect("192.168.173.100:3032")
# wait for connection ready (3s timeout)
yield uwsgi.wait_fd_write(fd, 3)
# wait for connection ready (3s timeout)
yield uwsgi.wait_fd_write(fd, 3)
# has timed out ?
if env['x-wsgiorg.fdevent.timeout']:
print "connection timed out !!!"
uwsgi.close(fd)
raise StopIteration
# has timed out ?
if env['x-wsgiorg.fdevent.timeout']:
print "connection timed out !!!"
uwsgi.close(fd)
raise StopIteration
# connection refused ?
if not uwsgi.is_connected(fd):
print "unable to connect"
uwsgi.close(fd)
raise StopIteration
# connection refused ?
if not uwsgi.is_connected(fd):
print "unable to connect"
uwsgi.close(fd)
raise StopIteration
# send request
# env can contains python objects, but send_message will discard them.
# In this way we will automagically have a congruent and valid uwsgi packet
uwsgi.async_send_message(fd, 0, 0, env)
# send request
# env can contains python objects, but send_message will discard them.
# In this way we will automagically have a congruent and valid uwsgi packet
uwsgi.async_send_message(fd, 0, 0, env)
# send the http body
# ready body in async mode and resend to fd
# uwsgi.recv will use always an internal buffer of 4096, but can be limited in the number of bytes to read
# send the http body
# ready body in async mode and resend to fd
# uwsgi.recv will use always an internal buffer of 4096, but can be limited in the number of bytes to read
# does this request has a body ?
cl = uwsgi.cl()
# does this request has a body ?
cl = uwsgi.cl()
if cl > 0:
# get the input fd
input = env['wsgi.input'].fileno()
if cl > 0:
# get the input fd
input = env['wsgi.input'].fileno()
# read (in async mode) upto 'cl' data and send to uwsgi peer
while cl > 0:
bufsize = min(cl, 4096)
yield uwsgi.wait_fd_read(input, 30)
if env['x-wsgiorg.fdevent.timeout']:
print "connection timed out !!!"
uwsgi.close(fd)
raise StopIteration
body = uwsgi.recv(input, bufsize)
if body:
uwsgi.send(fd, body)
cl = cl - len(body)
else:
break
# read (in async mode) upto 'cl' data and send to uwsgi peer
while cl > 0:
bufsize = min(cl, 4096)
yield uwsgi.wait_fd_read(input, 30)
if env['x-wsgiorg.fdevent.timeout']:
print "connection timed out !!!"
uwsgi.close(fd)
raise StopIteration
body = uwsgi.recv(input, bufsize)
if body:
uwsgi.send(fd, body)
cl = cl - len(body)
else:
break
# wait for response (30s timeout)
yield uwsgi.wait_fd_read(fd, 30)
# wait for response (30s timeout)
yield uwsgi.wait_fd_read(fd, 30)
# has timed out ?
if env['x-wsgiorg.fdevent.timeout']:
print "connection timed out !!!"
uwsgi.close(fd)
raise StopIteration
# has timed out ?
if env['x-wsgiorg.fdevent.timeout']:
print "connection timed out !!!"
uwsgi.close(fd)
raise StopIteration
data = uwsgi.recv(fd)
# recv the data, if it returns None the callable will end
while data:
yield data
# wait for response
yield uwsgi.wait_fd_read(fd, 30)
if env['x-wsgiorg.fdevent.timeout']:
print "connection timed out !!!"
uwsgi.close(fd)
raise StopIteration
data = uwsgi.recv(fd)
data = uwsgi.recv(fd)
# recv the data, if it returns None the callable will end
while data:
yield data
# wait for response
yield uwsgi.wait_fd_read(fd, 30)
if env['x-wsgiorg.fdevent.timeout']:
print "connection timed out !!!"
uwsgi.close(fd)
raise StopIteration
data = uwsgi.recv(fd)
uwsgi.close(fd)
uwsgi.close(fd)
+3 -3
View File
@@ -2,7 +2,7 @@
import uwsgi
def application(e,s):
def application(e, s):
for part in uwsgi.send_message("192.168.173.100:3032", 0, 0, e, 0, e['wsgi.input'].fileno(), uwsgi.cl()):
yield part
for part in uwsgi.send_message("192.168.173.100:3032", 0, 0, e, 0, e['wsgi.input'].fileno(), uwsgi.cl()):
yield part
+14 -13
View File
@@ -3,23 +3,24 @@ import uwsgi
current_node = 0
def application(e,s):
global current_node
def application(e, s):
nodes = uwsgi.cluster_nodes()
print nodes
global current_node
if len(nodes) == 0:
print "no cluster node available"
raise StopIteration
nodes = uwsgi.cluster_nodes()
print nodes
if current_node >= len(nodes):
current_node = 0
if len(nodes) == 0:
print "no cluster node available"
raise StopIteration
node = nodes[current_node]
if current_node >= len(nodes):
current_node = 0
for part in uwsgi.send_message(node, 0, 0, e, 0, e['wsgi.input'].fileno(), uwsgi.cl()):
yield part
node = nodes[current_node]
current_node+=1
for part in uwsgi.send_message(node, 0, 0, e, 0, e['wsgi.input'].fileno(), uwsgi.cl()):
yield part
current_node += 1
+9 -8
View File
@@ -1,14 +1,15 @@
import uwsgi
def application(e,s):
node = uwsgi.cluster_best_node()
print node
def application(e, s):
if not node:
print "sorry node unavailable"
raise StopIteration
node = uwsgi.cluster_best_node()
print node
for part in uwsgi.send_message(node, 0, 0, e, 0, e['wsgi.input'].fileno(), uwsgi.cl()):
yield part
if not node:
print "sorry node unavailable"
raise StopIteration
for part in uwsgi.send_message(node, 0, 0, e, 0, e['wsgi.input'].fileno(), uwsgi.cl()):
yield part
+4 -3
View File
@@ -3,7 +3,8 @@ import uwsgi
fd = uwsgi.connect("127.0.0.1:3033")
def application(e,s):
for part in uwsgi.send_message(fd, 0, 4, e, 30, e['wsgi.input'].fileno(), uwsgi.cl()):
yield part
def application(e, s):
for part in uwsgi.send_message(fd, 0, 4, e, 30, e['wsgi.input'].fileno(), uwsgi.cl()):
yield part
+5 -5
View File
@@ -36,7 +36,7 @@ def application(env, start_response):
yield "<h2>Hooks</h2>"
for h in range(0,255):
for h in range(0, 255):
if uwsgi.has_hook(h):
yield "%d<br/>" % h
@@ -45,15 +45,15 @@ def application(env, start_response):
yield '<table border="1">'
yield '<th>worker id</th><th>pid</th><th>in request</th><th>requests</th><th>running time</th><th>address space</th><th>rss</th>'
workers = uwsgi.workers();
workers = uwsgi.workers()
yield '<h2>workers</h2>'
for w in workers:
#print w
#print w['running_time']
# print w
# print w['running_time']
if w is not None:
yield '<tr><td>'+ str(w['id']) +'</td><td>' + str(w['pid']) + '</td><td>' + str(w['pid']) + '</td><td>' + str(w['requests']) + '</td><td>' + str(w['running_time']) + '</td><td>' + str(w['vsz']) + '</td><td>' + str(w['rss']) + '</td></tr>'
yield '<tr><td>' + str(w['id']) + '</td><td>' + str(w['pid']) + '</td><td>' + str(w['pid']) + '</td><td>' + str(w['requests']) + '</td><td>' + str(w['running_time']) + '</td><td>' + str(w['vsz']) + '</td><td>' + str(w['rss']) + '</td></tr>'
print w
yield '</table>'
+13 -11
View File
@@ -2,7 +2,8 @@ import uwsgi
import os
import gc
import sys
from uwsgidecorators import *
from uwsgidecorators import rpc, signal, postfork
print(sys.version)
print(sys.version_info)
if 'set_debug' in gc.__dict__:
@@ -26,6 +27,7 @@ def after_request_hook():
uwsgi.after_req_hook = after_request_hook
@rpc('hello')
def hello_rpc(one, two, three):
arg0 = one[::-1]
@@ -33,20 +35,24 @@ def hello_rpc(one, two, three):
arg2 = three[::-1]
return "!%s-%s-%s!" % (arg1, arg2, arg0)
@signal(17)
def ciao_mondo(signum):
print("Hello World")
def xsendfile(e, sr):
sr('200 OK', [('Content-Type', 'image/png'), ('X-Sendfile', os.path.abspath('logo_uWSGI.png'))])
return ''
def serve_logo(e, sr):
# use raw facilities (status will not be set...)
uwsgi.send("%s 200 OK\r\nContent-Type: image/png\r\n\r\n" % e['SERVER_PROTOCOL'])
uwsgi.sendfile('logo_uWSGI.png')
return ''
def serve_config(e, sr):
sr('200 OK', [('Content-Type', 'text/html')])
for opt in uwsgi.opt.keys():
@@ -57,11 +63,13 @@ routes['/xsendfile'] = xsendfile
routes['/logo'] = serve_logo
routes['/config'] = serve_config
@postfork
def setprocname():
if uwsgi.worker_id() > 0:
uwsgi.setprocname("i am the worker %d" % uwsgi.worker_id())
def application(env, start_response):
try:
uwsgi.mule_msg(env['REQUEST_URI'], 1)
@@ -82,7 +90,6 @@ def application(env, start_response):
if env['PATH_INFO'] in routes:
return routes[env['PATH_INFO']](env, start_response)
if DEBUG:
print(env['wsgi.input'].fileno())
@@ -98,7 +105,7 @@ def application(env, start_response):
for w in uwsgi.workers():
apps = '<table border="1"><tr><th>id</th><th>mountpoint</th><th>startup time</th><th>requests</th></tr>'
for app in w['apps']:
apps += '<tr><td>%d</td><td>%s</td><td>%d</td><td>%d</td></tr>' % (app['id'], app['mountpoint'], app['startup_time'], app['requests'])
apps += '<tr><td>%d</td><td>%s</td><td>%d</td><td>%d</td></tr>' % (app['id'], app['mountpoint'], app['startup_time'], app['requests'])
apps += '</table>'
workers += """
<tr>
@@ -122,14 +129,9 @@ Workers and applications<br/>
%s
</table>
""" % (uwsgi.version, uwsgi.hostname, env.get('REMOTE_USER','None'), workers)
""" % (uwsgi.version, uwsgi.hostname, env.get('REMOTE_USER', 'None'), workers)
start_response('200 OK', [('Content-Type', 'text/html'), ('Content-Length', str(len(output)) )])
start_response('200 OK', [('Content-Type', 'text/html'), ('Content-Length', str(len(output)))])
#return bytes(output.encode('latin1'))
# return bytes(output.encode('latin1'))
return output
+4 -6
View File
@@ -1,14 +1,17 @@
import uwsgi
import os
def xsendfile(e, sr):
sr('200 OK', [('Content-Type', 'image/png'), ('X-Sendfile', os.path.abspath('logo_uWSGI.png'))])
return b''
def serve_logo(e, sr):
sr('200 OK', [('Content-Type', 'image/png')])
return uwsgi.sendfile('logo_uWSGI.png')
def serve_config(e, sr):
sr('200 OK', [('Content-Type', 'text/html')])
for opt in uwsgi.opt.keys():
@@ -20,6 +23,7 @@ routes['/xsendfile'] = xsendfile
routes['/logo'] = serve_logo
routes['/config'] = serve_config
def application(env, start_response):
if env['PATH_INFO'] in routes:
@@ -39,9 +43,3 @@ Configuration<br/>
""".format(version=uwsgi.version.decode('ascii'))
return bytes(body.encode('ascii'))
+5 -3
View File
@@ -1,9 +1,11 @@
from uwsgiconfig import spcall
NAME='airbrake'
NAME = 'airbrake'
CFLAGS = [spcall('xml2-config --cflags')]
LDFLAGS = []
LIBS = ['-lcurl', spcall('xml2-config --libs')]
LIBS = [
'-lcurl',
spcall('xml2-config --libs')
]
GCC_LIST = ['airbrake_plugin']
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='alarm_curl'
NAME = 'alarm_curl'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,6 +1,6 @@
import os
NAME='alarm_speech'
NAME = 'alarm_speech'
uwsgi_os = os.uname()[0]
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='alarm_xmpp'
NAME = 'alarm_xmpp'
CFLAGS = []
LDFLAGS = []
+6 -3
View File
@@ -1,8 +1,11 @@
from distutils import sysconfig
NAME='asyncio'
CFLAGS = ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True)]
NAME = 'asyncio'
CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True)
]
LDFLAGS = []
LIBS = []
GCC_LIST = ['asyncio']
+1 -1
View File
@@ -1,5 +1,5 @@
NAME = 'cache'
NAME='cache'
CFLAGS = []
LDFLAGS = []
LIBS = []
+1 -2
View File
@@ -1,7 +1,6 @@
NAME = 'carbon'
NAME='carbon'
CFLAGS = []
LDFLAGS = []
LIBS = []
GCC_LIST = ['carbon']
+2 -1
View File
@@ -1,4 +1,5 @@
NAME='cgi'
NAME = 'cgi'
CFLAGS = []
LDFLAGS = []
LIBS = []
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='cheaper_backlog2'
NAME = 'cheaper_backlog2'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='cheaper_busyness'
NAME = 'cheaper_busyness'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='clock_monotonic'
NAME = 'clock_monotonic'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='clock_realtime'
NAME = 'clock_realtime'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,5 +1,5 @@
NAME = 'corerouter'
NAME='corerouter'
CFLAGS = []
LDFLAGS = []
LIBS = []
+2 -1
View File
@@ -1,6 +1,8 @@
import os
import sys
NAME = 'coroae'
coroapi = None
search_paths = os.popen('perl -MConfig -e \'print $Config{sitearch}.",".join(",", @INC);\'').read().rstrip().split(',')
@@ -12,7 +14,6 @@ if not coroapi:
print "unable to find the Coro perl module !!!"
sys.exit(1)
NAME='coroae'
CFLAGS = os.popen('perl -MExtUtils::Embed -e ccopts').read().rstrip().split()
CFLAGS += ['-Wno-int-to-pointer-cast', '-Wno-error=format', '-Wno-error=int-to-pointer-cast', '-I%s/Coro' % coroapi]
LDFLAGS = []
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='cplusplus'
NAME = 'cplusplus'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='curl_cron'
NAME = 'curl_cron'
CFLAGS = []
LDFLAGS = []
+2 -2
View File
@@ -1,6 +1,6 @@
NAME='dumbloop'
NAME = 'dumbloop'
CFLAGS = []
LDFLAGS = []
LIBS = []
GCC_LIST = ['dumb']
+1 -2
View File
@@ -1,7 +1,6 @@
NAME = 'dummy'
NAME='dummy'
CFLAGS = []
LDFLAGS = []
LIBS = []
GCC_LIST = ['dummy']
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='echo'
NAME = 'echo'
CFLAGS = []
LDFLAGS = []
+2 -2
View File
@@ -1,7 +1,7 @@
NAME = 'emperor_amqp'
NAME='emperor_amqp'
CFLAGS = []
LDFLAGS = []
LIBS = []
GCC_LIST = ['amqp','emperor_amqp']
GCC_LIST = ['amqp', 'emperor_amqp']
+6 -3
View File
@@ -1,12 +1,15 @@
import os
NAME='emperor_mongodb'
NAME = 'emperor_mongodb'
CFLAGS = ['-I/usr/include/mongo','-I/usr/local/include/mongo']
CFLAGS = [
'-I/usr/include/mongo',
'-I/usr/local/include/mongo'
]
LDFLAGS = []
LIBS = ['-lstdc++']
if not 'UWSGI_MONGODB_NOLIB' in os.environ:
if 'UWSGI_MONGODB_NOLIB' not in os.environ:
LIBS.append('-lmongoclient')
LIBS.append('-lboost_thread')
LIBS.append('-lboost_filesystem')
+6 -2
View File
@@ -1,9 +1,13 @@
import os
NAME='emperor_pg'
NAME = 'emperor_pg'
CFLAGS = os.popen('pg_config --cflags').read().rstrip().split()
CFLAGS.append('-I' + os.popen('pg_config --includedir').read().rstrip())
LDFLAGS = os.popen('pg_config --ldflags').read().rstrip().split()
LIBS = ['-L' + os.popen('pg_config --libdir').read().rstrip(), '-lpq']
LIBS = [
'-L' + os.popen('pg_config --libdir').read().rstrip(),
'-lpq'
]
GCC_LIST = ['emperor_pg']
+1 -1
View File
@@ -1,5 +1,5 @@
NAME = 'emperor_zeromq'
NAME='emperor_zeromq'
CFLAGS = []
LDFLAGS = []
LIBS = ['-lzmq']
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='example'
NAME = 'example'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='exception_log'
NAME = 'exception_log'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,5 +1,5 @@
NAME = 'fastrouter'
NAME='fastrouter'
CFLAGS = []
LDFLAGS = []
LIBS = []
+1 -1
View File
@@ -1,6 +1,6 @@
import os
NAME='fiber'
NAME = 'fiber'
try:
RUBYPATH = os.environ['UWSGICONFIG_RUBYPATH']
+2 -1
View File
@@ -1,7 +1,8 @@
import os
uwsgi_os = os.uname()[0]
NAME='forkptyrouter'
NAME = 'forkptyrouter'
CFLAGS = []
LDFLAGS = []
if uwsgi_os in ('Linux', 'FreeBSD', 'GNU', 'NetBSD', 'DragonFly'):
+3 -1
View File
@@ -1,11 +1,13 @@
import os
NAME='gccgo'
NAME = 'gccgo'
CFLAGS = ['-g']
LDFLAGS = []
LIBS = ['-lgo']
GCC_LIST = ['gccgo_plugin', 'uwsgi.go']
def post_build(config):
if os.path.exists('plugins/gccgo/uwsgi.go.o'):
if os.system("objcopy -j .go_export plugins/gccgo/uwsgi.go.o plugins/gccgo/uwsgi.gox") != 0:
+1 -2
View File
@@ -1,8 +1,7 @@
NAME='geoip'
NAME = 'geoip'
CFLAGS = []
LDFLAGS = []
LIBS = ['-lGeoIP']
GCC_LIST = ['geoip']
+6 -2
View File
@@ -1,7 +1,11 @@
from distutils import sysconfig
NAME='gevent'
CFLAGS = ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True)]
NAME = 'gevent'
CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True)
]
LDFLAGS = []
LIBS = []
+3 -2
View File
@@ -1,7 +1,8 @@
import os
NAME='glusterfs'
NAME = 'glusterfs'
CFLAGS = os.popen('pkg-config --cflags glusterfs-api').read().rstrip().split()
LDFLAGS = []
LIBS = os.popen('pkg-config --libs glusterfs-api').read().rstrip().split()
LIBS = os.popen('pkg-config --libs glusterfs-api').read().rstrip().split()
GCC_LIST = ['glusterfs']
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='graylog2'
NAME = 'graylog2'
CFLAGS = []
LDFLAGS = []
+6 -2
View File
@@ -1,7 +1,11 @@
from distutils import sysconfig
NAME='greenlet'
CFLAGS = ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True)]
NAME = 'greenlet'
CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True)
]
LDFLAGS = []
LIBS = []
+6 -3
View File
@@ -1,12 +1,15 @@
import os
NAME='gridfs'
NAME = 'gridfs'
CFLAGS = ['-I/usr/include/mongo','-I/usr/local/include/mongo']
CFLAGS = [
'-I/usr/include/mongo',
'-I/usr/local/include/mongo'
]
LDFLAGS = []
LIBS = []
if not 'UWSGI_MONGODB_NOLIB' in os.environ:
if 'UWSGI_MONGODB_NOLIB' not in os.environ:
LIBS.append('-lmongoclient')
LIBS.append('-lstdc++')
LIBS.append('-lboost_thread')
+1 -1
View File
@@ -1,5 +1,5 @@
NAME = 'http'
NAME='http'
CFLAGS = []
LDFLAGS = []
LIBS = []
+11 -11
View File
@@ -1,7 +1,7 @@
import os
import shutil
NAME='jvm'
NAME = 'jvm'
JVM_INCPATH = None
JVM_LIBPATH = None
@@ -33,15 +33,15 @@ elif operating_system.startswith('cygwin'):
else:
known_jvms = ('/usr/lib/jvm/java-7-openjdk', '/usr/local/openjdk7', '/usr/lib/jvm/java-6-openjdk', '/usr/local/openjdk', '/usr/java', '/usr/lib/jvm/java/')
for jvm in known_jvms:
if os.path.exists(jvm + '/include'):
JVM_INCPATH = ["-I%s/include/" % jvm, "-I%s/include/%s" % (jvm, operating_system)]
JVM_LIBPATH = ["-L%s/jre/lib/%s/server" % (jvm, arch)]
break
if os.path.exists("%s-%s/include" % (jvm, arch)):
jvm = "%s-%s" % (jvm, arch)
JVM_INCPATH = ["-I%s/include/" % jvm, "-I%s/include/%s" % (jvm, operating_system)]
JVM_LIBPATH = ["-L%s/jre/lib/%s/server" % (jvm, arch)]
break
if os.path.exists(jvm + '/include'):
JVM_INCPATH = ["-I%s/include/" % jvm, "-I%s/include/%s" % (jvm, operating_system)]
JVM_LIBPATH = ["-L%s/jre/lib/%s/server" % (jvm, arch)]
break
if os.path.exists("%s-%s/include" % (jvm, arch)):
jvm = "%s-%s" % (jvm, arch)
JVM_INCPATH = ["-I%s/include/" % jvm, "-I%s/include/%s" % (jvm, operating_system)]
JVM_LIBPATH = ["-L%s/jre/lib/%s/server" % (jvm, arch)]
break
try:
JVM_INCPATH = ['-I"' + os.environ['UWSGICONFIG_JVM_INCPATH'] + '"']
@@ -70,6 +70,7 @@ if 'LD_RUN_PATH' in os.environ:
else:
os.environ['LD_RUN_PATH'] = JVM_LIBPATH[0][2:]
def post_build(config):
if os.system("javac %s/plugins/jvm/uwsgi.java" % os.getcwd()) != 0:
os._exit(1)
@@ -89,4 +90,3 @@ def post_build(config):
tgt = "%s/bin/jvm_plugin.so" % env
shutil.copyfile(plugin, tgt)
print("*** jvm_plugin.so had been copied to %s" % tgt)
+2 -1
View File
@@ -1,3 +1,5 @@
NAME = 'jwsgi'
jvm_path = 'plugins/jvm'
up = {}
@@ -8,7 +10,6 @@ except:
exec(f.read(), up)
f.close()
NAME='jwsgi'
CFLAGS = up['CFLAGS']
CFLAGS.append('-I%s' % jvm_path)
LDFLAGS = []
+1 -1
View File
@@ -1,5 +1,5 @@
NAME = 'ldap'
NAME='ldap'
CFLAGS = []
LDFLAGS = []
LIBS = ['-lldap']
+1 -2
View File
@@ -1,8 +1,7 @@
NAME = 'legion_cache_fetch'
CFLAGS = []
LDFLAGS = []
LIBS = []
GCC_LIST = ['legion_cache_fetch']
+6 -5
View File
@@ -1,5 +1,6 @@
NAME='libffi'
CFLAGS=[]
LDFLAGS=[]
LIBS=['-lffi']
GCC_LIST=['libffi']
NAME = 'libffi'
CFLAGS = []
LDFLAGS = []
LIBS = ['-lffi']
GCC_LIST = ['libffi']
+6 -5
View File
@@ -1,5 +1,6 @@
NAME='libtcc'
CFLAGS=[]
LDFLAGS=[]
LIBS=['-ltcc']
GCC_LIST=['libtcc']
NAME = 'libtcc'
CFLAGS = []
LDFLAGS = []
LIBS = ['-ltcc']
GCC_LIST = ['libtcc']
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='logcrypto'
NAME = 'logcrypto'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='logfile'
NAME = 'logfile'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='logpipe'
NAME = 'logpipe'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='logsocket'
NAME = 'logsocket'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,5 +1,5 @@
NAME = 'logzmq'
NAME='logzmq'
CFLAGS = []
LDFLAGS = []
LIBS = ['-lzmq']
+15 -16
View File
@@ -1,4 +1,6 @@
import os,sys
import os
NAME = 'lua'
LUAINC = os.environ.get('UWSGICONFIG_LUAINC')
LUALIB = os.environ.get('UWSGICONFIG_LUALIB')
@@ -7,27 +9,24 @@ LUAPC = os.environ.get('UWSGICONFIG_LUAPC', 'lua5.1')
# we LUAINC/LUALIB/LUALIBPATH override the LUAPC for backwards compat
if LUAINC:
CFLAGS = ['-I%s' % LUAINC]
CFLAGS = ['-I%s' % LUAINC]
else:
try:
CFLAGS = os.popen('pkg-config --cflags %s' % LUAPC).read().rstrip().split()
except:
CFLAGS = ['-I/usr/include/lua5.1']
try:
CFLAGS = os.popen('pkg-config --cflags %s' % LUAPC).read().rstrip().split()
except:
CFLAGS = ['-I/usr/include/lua5.1']
if LUALIB:
LIBS = ['-l%s' % LUALIB]
LIBS = ['-l%s' % LUALIB]
else:
try:
LIBS = os.popen('pkg-config --libs %s' % LUAPC).read().rstrip().split()
except:
LIBS = ['-llua5.1']
try:
LIBS = os.popen('pkg-config --libs %s' % LUAPC).read().rstrip().split()
except:
LIBS = ['-llua5.1']
if LUALIBPATH:
LDFLAGS = ['-L%s' % LUALIBPATH]
LDFLAGS = ['-L%s' % LUALIBPATH]
else:
LDFLAGS = []
LDFLAGS = []
NAME='lua'
GCC_LIST = ['lua_plugin']
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='matheval'
NAME = 'matheval'
CFLAGS = []
LDFLAGS = []
+9 -4
View File
@@ -1,8 +1,13 @@
NAME='mongodb'
NAME = 'mongodb'
CFLAGS = []
LDFLAGS = []
LIBS = ['-Wl,-whole-archive', '-lmongoclient', '-Wl,-no-whole-archive', '-lboost_thread', '-lboost_system', '-lboost_filesystem']
LIBS = [
'-Wl,-whole-archive',
'-lmongoclient',
'-Wl,-no-whole-archive',
'-lboost_thread',
'-lboost_system',
'-lboost_filesystem'
]
GCC_LIST = ['plugin']
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='mongodblog'
NAME = 'mongodblog'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,5 +1,5 @@
NAME = 'mongrel2'
NAME='mongrel2'
CFLAGS = []
LDFLAGS = []
LIBS = ['-lzmq']
+4 -2
View File
@@ -1,14 +1,16 @@
import os
NAME='mono'
NAME = 'mono'
CFLAGS = os.popen('pkg-config --cflags mono-2').read().rstrip().split()
LDFLAGS = []
LIBS = os.popen('pkg-config --libs mono-2').read().rstrip().split()
LIBS = os.popen('pkg-config --libs mono-2').read().rstrip().split()
GCC_LIST = ['mono_plugin']
if os.uname()[0] == 'Darwin':
LIBS.append('-framework Foundation')
def post_build(config):
if os.system("sn -k plugins/mono/uwsgi.key") != 0:
os._exit(1)
+4 -4
View File
@@ -1,5 +1,5 @@
NAME='msgpack'
CFLAGS=[]
LDFLAGS=[]
LIBS=[]
NAME = 'msgpack'
CFLAGS = []
LDFLAGS = []
LIBS = []
GCC_LIST = ['msgpack']
+1 -1
View File
@@ -1,5 +1,5 @@
NAME = 'nagios'
NAME='nagios'
CFLAGS = []
LDFLAGS = []
LIBS = []
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='notfound'
NAME = 'notfound'
CFLAGS = []
LDFLAGS = []
+5 -5
View File
@@ -1,5 +1,5 @@
NAME="objc_gc"
CFLAGS=["-fobjc-gc"]
LDFLAGS=[]
LIBS=[]
GCC_LIST=['objc_gc.m']
NAME = "objc_gc"
CFLAGS = ["-fobjc-gc"]
LDFLAGS = []
LIBS = []
GCC_LIST = ['objc_gc.m']
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='pam'
NAME = 'pam'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,6 +1,6 @@
import os
NAME='php'
NAME = 'php'
ld_run_path = None
PHPPATH = 'php-config'
+2 -1
View File
@@ -1,4 +1,5 @@
NAME='ping'
NAME = 'ping'
CFLAGS = []
LDFLAGS = []
LIBS = []
+2 -2
View File
@@ -1,6 +1,6 @@
import os,sys
import os
NAME='psgi'
NAME = 'psgi'
CFLAGS = os.popen('perl -MExtUtils::Embed -e ccopts').read().rstrip().split()
LDFLAGS = os.popen('perl -MExtUtils::Embed -e ldopts').read().rstrip().split()
LIBS = []
+3 -2
View File
@@ -1,6 +1,7 @@
NAME='pty'
import os
NAME = 'pty'
uwsgi_os = os.uname()[0]
CFLAGS = []
+211 -170
View File
@@ -1,7 +1,7 @@
import sys
import os
sys.path.insert(0, '.')
sys.path.extend(os.environ.get('PYTHONPATH','').split(os.pathsep))
sys.path.extend(os.environ.get('PYTHONPATH', '').split(os.pathsep))
import imp
import traceback
@@ -53,10 +53,10 @@ for cflag in uwsgi_cflags:
if '=' in line:
(key, value) = line.split('=', 1)
uwsgi_cdef.append('#define %s ...' % key)
uwsgi_defines.append('#define %s %s' % (key, value.replace('\\"','"').replace('""','"')))
uwsgi_defines.append('#define %s %s' % (key, value.replace('\\"', '"').replace('""', '"')))
else:
uwsgi_cdef.append('#define %s ...' % line)
uwsgi_defines.append('#define %s 1' % line)
uwsgi_defines.append('#define %s 1' % line)
uwsgi_dot_h = ffi.string(lib0.uwsgi_get_dot_h())
# uwsgi definitions
@@ -64,107 +64,107 @@ cdefines = '''
%s
struct iovec {
void *iov_base;
size_t iov_len;
...;
void *iov_base;
size_t iov_len;
...;
};
struct uwsgi_header {
uint8_t modifier1;
...;
uint8_t modifier1;
...;
};
struct wsgi_request {
int fd;
int async_id;
uint16_t var_cnt;
struct iovec *hvec;
int fd;
int async_id;
uint16_t var_cnt;
struct iovec *hvec;
int async_ready_fd;
int async_last_ready_fd;
int async_ready_fd;
int async_last_ready_fd;
int suspended;
int suspended;
struct uwsgi_header *uh;
...;
struct uwsgi_header *uh;
...;
};
struct uwsgi_opt {
char *key;
char *value;
...;
char *key;
char *value;
...;
};
struct uwsgi_worker {
int id;
int pid;
uint64_t requests;
uint64_t delta_requests;
uint64_t signals;
int id;
int pid;
uint64_t requests;
uint64_t delta_requests;
uint64_t signals;
int cheaped;
int suspended;
int sig;
uint8_t signum;
int cheaped;
int suspended;
int sig;
uint8_t signum;
uint64_t running_time;
uint64_t avg_response_time;
uint64_t tx;
...;
uint64_t running_time;
uint64_t avg_response_time;
uint64_t tx;
...;
};
struct uwsgi_plugin {
uint8_t modifier1;
uint8_t modifier1;
void (*suspend) (struct wsgi_request *);
void (*suspend) (struct wsgi_request *);
void (*resume) (struct wsgi_request *);
...;
...;
};
struct uwsgi_buffer {
char *buf;
size_t pos;
...;
char *buf;
size_t pos;
...;
};
struct uwsgi_lock_item {
...;
...;
};
struct uwsgi_cache {
struct uwsgi_lock_item *lock;
...;
struct uwsgi_lock_item *lock;
...;
};
struct uwsgi_cache_item {
uint64_t keysize;
...;
uint64_t keysize;
...;
};
struct uwsgi_server {
char hostname[];
int mywid;
int muleid;
int master_process;
char hostname[];
int mywid;
int muleid;
int master_process;
struct uwsgi_opt **exported_opts;
int exported_opts_cnt;
struct uwsgi_opt **exported_opts;
int exported_opts_cnt;
struct uwsgi_worker *workers;
struct uwsgi_worker *workers;
int signal_socket;
int numproc;
int async;
int signal_socket;
int numproc;
int async;
void (*schedule_to_main) (struct wsgi_request *);
void (*schedule_to_main) (struct wsgi_request *);
void (*schedule_to_req) (void);
struct wsgi_request *(*current_wsgi_req) (void);
struct wsgi_request *wsgi_req;
struct wsgi_request *(*current_wsgi_req) (void);
struct uwsgi_plugin *p[];
...;
struct wsgi_request *wsgi_req;
struct uwsgi_plugin *p[];
...;
};
struct uwsgi_server uwsgi;
@@ -267,7 +267,6 @@ lib = ffi.verify(cverify)
libc = ffi.dlopen(None)
"""
this is a global object point the the WSGI callable
it sucks, i will fix it in the near future...
@@ -278,20 +277,22 @@ wsgi_application = None
if len(sys.argv) == 0:
sys.argv.insert(0, ffi.string(lib.uwsgi_binary_path()))
"""
execute source, we expose it as cffi callback to avoid deadlocks
after GIL initialization
"""
@ffi.callback("void(char *)")
def uwsgi_pypy_execute_source(s):
"""
execute source, we expose it as cffi callback to avoid deadlocks
after GIL initialization
"""
source = ffi.string(s)
exec(source)
"""
load a wsgi module
"""
@ffi.callback("void(char *)")
def uwsgi_pypy_loader(module):
"""
load a wsgi module
"""
global wsgi_application
m = ffi.string(module)
c = 'application'
@@ -303,22 +304,24 @@ def uwsgi_pypy_loader(module):
mod = __import__(m)
wsgi_application = getattr(mod, c)
"""
load a mod_wsgi compliant .wsgi file
"""
@ffi.callback("void(char *)")
def uwsgi_pypy_file_loader(filename):
"""
load a mod_wsgi compliant .wsgi file
"""
global wsgi_application
w = ffi.string(filename)
c = 'application'
mod = imp.load_source('uwsgi_file_wsgi', w)
wsgi_application = getattr(mod, c)
"""
load a .ini paste app
"""
@ffi.callback("void(char *)")
def uwsgi_pypy_paste_loader(config):
"""
load a .ini paste app
"""
global wsgi_application
c = ffi.string(config)
if c.startswith('config:'):
@@ -333,29 +336,31 @@ def uwsgi_pypy_paste_loader(config):
from paste.deploy import loadapp
wsgi_application = loadapp('config:%s' % c)
"""
.post_fork_hook
"""
@ffi.callback("void()")
def uwsgi_pypy_post_fork_hook():
"""
.post_fork_hook
"""
import uwsgi
if hasattr(uwsgi, 'post_fork_hook'):
uwsgi.post_fork_hook()
"""
add an item to the pythonpath
"""
@ffi.callback("void(char *)")
def uwsgi_pypy_pythonpath(item):
"""
add an item to the pythonpath
"""
path = ffi.string(item)
sys.path.append(path)
print "added %s to pythonpath" % path
"""
class implementing wsgi.file_wrapper
"""
class WSGIfilewrapper(object):
"""
class implementing wsgi.file_wrapper
"""
def __init__(self, wsgi_req, f, chunksize=0):
self.wsgi_req = wsgi_req
self.f = f
@@ -382,10 +387,10 @@ class WSGIfilewrapper(object):
lib.uwsgi_response_write_body_do(self.wsgi_req, ffi.new("char[]", chunk), len(chunk))
"""
class implementing wsgi.input
"""
class WSGIinput(object):
"""
class implementing wsgi.input
"""
def __init__(self, wsgi_req):
self.wsgi_req = wsgi_req
@@ -429,11 +434,11 @@ class WSGIinput(object):
return chunk
"""
the WSGI request handler
"""
@ffi.callback("void(struct wsgi_request *)")
def uwsgi_pypy_wsgi_handler(wsgi_req):
"""
the WSGI request handler
"""
import uwsgi
global wsgi_application
@@ -506,6 +511,7 @@ sys.modules['uwsgi'] = uwsgi
uwsgi.version = ffi.string(lib.uwsgi_pypy_version)
uwsgi.hostname = ffi.string(lib.uwsgi.hostname)
def uwsgi_pypy_uwsgi_register_signal(signum, kind, handler):
cb = ffi.callback('void(int)', handler)
uwsgi_gc.append(cb)
@@ -538,6 +544,7 @@ def uwsgi_pypy_uwsgi_register_rpc(name, func, argc=0):
raise Exception("unable to register rpc func %s" % name)
uwsgi.register_rpc = uwsgi_pypy_uwsgi_register_rpc
def uwsgi_pypy_rpc(node, func, *args):
argc = 0
argv = ffi.new('char*[256]')
@@ -558,7 +565,7 @@ def uwsgi_pypy_rpc(node, func, *args):
else:
c_node = ffi.NULL
response = lib.uwsgi_do_rpc(c_node, ffi.new("char[]",func), argc, argv, argvs, rsize)
response = lib.uwsgi_do_rpc(c_node, ffi.new("char[]", func), argc, argv, argvs, rsize)
if response:
ret = ffi.string(response, rsize[0])
lib.free(response)
@@ -566,13 +573,14 @@ def uwsgi_pypy_rpc(node, func, *args):
return None
uwsgi.rpc = uwsgi_pypy_rpc
def uwsgi_pypy_call(func, *args):
node = None
if '@' in func:
(func, node) = func.split('@')
return uwsgi_pypy_rpc(node, func, *args)
uwsgi.call = uwsgi_pypy_call
uwsgi.signal = lambda x: lib.uwsgi_signal_send(lib.uwsgi.signal_socket, x)
uwsgi.metric_get = lambda x: lib.uwsgi_metric_get(x, ffi.NULL)
@@ -582,6 +590,7 @@ uwsgi.metric_dec = lambda x, y=1: lib.uwsgi_metric_dec(x, ffi.NULL, y)
uwsgi.metric_mul = lambda x, y=1: lib.uwsgi_metric_mul(x, ffi.NULL, y)
uwsgi.metric_div = lambda x, y=1: lib.uwsgi_metric_div(x, ffi.NULL, y)
def uwsgi_pypy_uwsgi_cache_get(key, cache=ffi.NULL):
vallen = ffi.new('uint64_t*')
value = lib.uwsgi_cache_magic_get(key, len(key), vallen, ffi.NULL, cache)
@@ -592,21 +601,25 @@ def uwsgi_pypy_uwsgi_cache_get(key, cache=ffi.NULL):
return ret
uwsgi.cache_get = uwsgi_pypy_uwsgi_cache_get
def uwsgi_pypy_uwsgi_cache_set(key, value, expires=0, cache=ffi.NULL):
if lib.uwsgi_cache_magic_set(key, len(key), value, len(value), expires, 0, cache) < 0:
raise Exception('unable to store item in the cache')
uwsgi.cache_set = uwsgi_pypy_uwsgi_cache_set
def uwsgi_pypy_uwsgi_cache_update(key, value, expires=0, cache=ffi.NULL):
if lib.uwsgi_cache_magic_set(key, len(key), value, len(value), expires, 1 << 1, cache) < 0:
raise Exception('unable to store item in the cache')
uwsgi.cache_update = uwsgi_pypy_uwsgi_cache_update
def uwsgi_pypy_uwsgi_cache_del(key, cache=ffi.NULL):
if lib.uwsgi_cache_magic_del(key, len(key), cache) < 0:
raise Exception('unable to delete item from the cache')
uwsgi.cache_del = uwsgi_pypy_uwsgi_cache_del
def uwsgi_pypy_uwsgi_cache_keys(cache=ffi.NULL):
uc = lib.uwsgi_cache_by_name(cache)
if uc == ffi.NULL:
@@ -617,17 +630,20 @@ def uwsgi_pypy_uwsgi_cache_keys(cache=ffi.NULL):
uci = ffi.new('struct uwsgi_cache_item **')
while True:
uci[0] = lib.uwsgi_cache_keys(uc, pos, uci)
if uci[0] == ffi.NULL: break
if uci[0] == ffi.NULL:
break
l.append(ffi.string(lib.uwsgi_cache_item_key(uci[0]), uci[0].keysize))
lib.uwsgi_cache_rwunlock(uc)
return l
uwsgi.cache_keys = uwsgi_pypy_uwsgi_cache_keys
def uwsgi_pypy_uwsgi_add_timer(signum, secs):
if lib.uwsgi_add_timer(signum, secs) < 0:
raise Exception("unable to register timer")
uwsgi.add_timer = uwsgi_pypy_uwsgi_add_timer
def uwsgi_pypy_uwsgi_add_rb_timer(signum, secs):
if lib.uwsgi_signal_add_rb_timer(signum, secs, 0) < 0:
raise Exception("unable to register redblack timer")
@@ -639,16 +655,19 @@ def uwsgi_pypy_uwsgi_add_file_monitor(signum, filename):
raise Exception("unable to register file monitor")
uwsgi.add_file_monitor = uwsgi_pypy_uwsgi_add_file_monitor
def uwsgi_pypy_lock(num=0):
if lib.uwsgi_user_lock(num) < 0:
raise Exception("invalid lock")
uwsgi.lock = uwsgi_pypy_lock
def uwsgi_pypy_unlock(num=0):
if lib.uwsgi_user_unlock(num) < 0:
raise Exception("invalid lock")
uwsgi.unlock = uwsgi_pypy_unlock
def uwsgi_pypy_masterpid():
if lib.uwsgi.master_process:
return lib.uwsgi.workers[0].pid
@@ -659,18 +678,21 @@ uwsgi.worker_id = lambda: lib.uwsgi.mywid
uwsgi.mule_id = lambda: lib.uwsgi.muleid
def uwsgi_pypy_signal_registered(signum):
if lib.uwsgi_signal_registered(signum) > 0:
return True
return False
uwsgi.signal_registered = uwsgi_pypy_signal_registered
def uwsgi_pypy_alarm(alarm, msg):
lib.uwsgi_alarm_trigger(ffi.new('char[]', alarm), ffi.new('char[]', msg), len(msg))
uwsgi.alarm = uwsgi_pypy_alarm
uwsgi.setprocname = lambda name: lib.uwsgi_set_processname(ffi.new('char[]', name))
def uwsgi_pypy_add_cron(signum, minute, hour, day, month, week):
if lib.uwsgi_signal_add_cron(signum, minute, hour, day, month, week) < 0:
raise Exception("unable to register cron")
@@ -695,25 +717,28 @@ for i in range(0, lib.uwsgi.exported_opts_cnt):
else:
uwsgi.opt[k] = v
def uwsgi_pypy_current_wsgi_req():
wsgi_req = lib.uwsgi.current_wsgi_req()
if wsgi_req == ffi.NULL:
raise Exception("unable to get current wsgi_request, check your setup !!!")
return wsgi_req
"""
uwsgi.suspend()
"""
def uwsgi_pypy_suspend():
"""
uwsgi.suspend()
"""
wsgi_req = uwsgi_pypy_current_wsgi_req()
if lib.uwsgi.schedule_to_main:
lib.uwsgi.schedule_to_main(wsgi_req);
lib.uwsgi.schedule_to_main(wsgi_req)
uwsgi.suspend = uwsgi_pypy_suspend
"""
uwsgi.workers()
"""
def uwsgi_pypy_workers():
"""
uwsgi.workers()
"""
workers = []
for i in range(1, lib.uwsgi.numproc+1):
worker = {}
@@ -722,7 +747,7 @@ def uwsgi_pypy_workers():
worker['requests'] = lib.uwsgi.workers[i].requests
worker['delta_requests'] = lib.uwsgi.workers[i].delta_requests
worker['signals'] = lib.uwsgi.workers[i].signals
worker['exceptions'] = lib.uwsgi_worker_exceptions(i);
worker['exceptions'] = lib.uwsgi_worker_exceptions(i)
worker['apps'] = []
if lib.uwsgi.workers[i].cheaped:
worker['status'] == 'cheap'
@@ -732,31 +757,33 @@ def uwsgi_pypy_workers():
if lib.uwsgi.workers[i].sig:
worker['status'] = 'sig%d' % lib.uwsgi.workers[i].signum
elif lib.uwsgi_worker_is_busy(i):
worker['status'] = 'busy'
worker['status'] = 'busy'
else:
worker['status'] = 'idle'
worker['running_time'] = lib.uwsgi.workers[i].running_time
worker['avg_rt'] = lib.uwsgi.workers[i].avg_response_time
worker['tx'] = lib.uwsgi.workers[i].tx
workers.append(worker)
return workers
uwsgi.workers = uwsgi_pypy_workers
"""
uwsgi.async_sleep(timeout)
"""
def uwsgi_pypy_async_sleep(timeout):
"""
uwsgi.async_sleep(timeout)
"""
if timeout > 0:
wsgi_req = uwsgi_pypy_current_wsgi_req();
lib.async_add_timeout(wsgi_req, timeout);
wsgi_req = uwsgi_pypy_current_wsgi_req()
lib.async_add_timeout(wsgi_req, timeout)
uwsgi.async_sleep = uwsgi_pypy_async_sleep
"""
uwsgi.async_connect(addr)
"""
def uwsgi_pypy_async_connect(addr):
"""
uwsgi.async_connect(addr)
"""
fd = lib.uwsgi_connect(ffi.new('char[]', addr), 0, 1)
if fd < 0:
raise Exception("unable to connect to %s" % addr)
@@ -765,41 +792,44 @@ uwsgi.async_connect = uwsgi_pypy_async_connect
uwsgi.connection_fd = lambda: uwsgi_pypy_current_wsgi_req().fd
"""
uwsgi.wait_fd_read(fd, timeout=0)
"""
def uwsgi_pypy_wait_fd_read(fd, timeout=0):
wsgi_req = uwsgi_pypy_current_wsgi_req();
"""
uwsgi.wait_fd_read(fd, timeout=0)
"""
wsgi_req = uwsgi_pypy_current_wsgi_req()
if lib.async_add_fd_read(wsgi_req, fd, timeout) < 0:
raise Exception("unable to add fd %d to the event queue" % fd)
uwsgi.wait_fd_read = uwsgi_pypy_wait_fd_read
"""
uwsgi.wait_fd_write(fd, timeout=0)
"""
def uwsgi_pypy_wait_fd_write(fd, timeout=0):
wsgi_req = uwsgi_pypy_current_wsgi_req();
"""
uwsgi.wait_fd_write(fd, timeout=0)
"""
wsgi_req = uwsgi_pypy_current_wsgi_req()
if lib.async_add_fd_write(wsgi_req, fd, timeout) < 0:
raise Exception("unable to add fd %d to the event queue" % fd)
uwsgi.wait_fd_write = uwsgi_pypy_wait_fd_write
"""
uwsgi.ready_fd()
"""
def uwsgi_pypy_ready_fd():
wsgi_req = uwsgi_pypy_current_wsgi_req();
"""
uwsgi.ready_fd()
"""
wsgi_req = uwsgi_pypy_current_wsgi_req()
return lib.uwsgi_ready_fd(wsgi_req)
uwsgi.ready_fd = uwsgi_pypy_ready_fd
"""
uwsgi.send(fd=None,data)
"""
def uwsgi_pypy_send(*args):
"""
uwsgi.send(fd=None,data)
"""
if len(args) == 0:
raise ValueError("uwsgi.send() takes at least 1 argument")
elif len(args) == 1:
wsgi_req = uwsgi_pypy_current_wsgi_req();
wsgi_req = uwsgi_pypy_current_wsgi_req()
fd = wsgi_req.fd
data = args[0]
else:
@@ -811,14 +841,15 @@ def uwsgi_pypy_send(*args):
return rlen
uwsgi.send = uwsgi_pypy_send
"""
uwsgi.recv(fd=None,len)
"""
def uwsgi_pypy_recv(*args):
"""
uwsgi.recv(fd=None,len)
"""
if len(args) == 0:
raise ValueError("uwsgi.recv() takes at least 1 argument")
elif len(args) == 1:
wsgi_req = uwsgi_pypy_current_wsgi_req();
wsgi_req = uwsgi_pypy_current_wsgi_req()
fd = wsgi_req.fd
l = args[0]
else:
@@ -830,7 +861,7 @@ def uwsgi_pypy_recv(*args):
raise IOError("unable to receive data")
return ffi.string(data[0:rlen])
uwsgi.recv = uwsgi_pypy_recv
"""
uwsgi.close(fd)
"""
@@ -841,12 +872,13 @@ uwsgi.disconnect()
"""
uwsgi.disconnect = lambda: lib.uwsgi_disconnect(uwsgi_pypy_current_wsgi_req())
"""
uwsgi.websocket_recv()
"""
def uwsgi_pypy_websocket_recv():
wsgi_req = uwsgi_pypy_current_wsgi_req();
ub = lib.uwsgi_websocket_recv(wsgi_req);
"""
uwsgi.websocket_recv()
"""
wsgi_req = uwsgi_pypy_current_wsgi_req()
ub = lib.uwsgi_websocket_recv(wsgi_req)
if ub == ffi.NULL:
raise IOError("unable to receive websocket message")
ret = ffi.string(ub.buf, ub.pos)
@@ -854,12 +886,13 @@ def uwsgi_pypy_websocket_recv():
return ret
uwsgi.websocket_recv = uwsgi_pypy_websocket_recv
"""
uwsgi.websocket_recv_nb()
"""
def uwsgi_pypy_websocket_recv_nb():
wsgi_req = uwsgi_pypy_current_wsgi_req();
ub = lib.uwsgi_websocket_recv_nb(wsgi_req);
"""
uwsgi.websocket_recv_nb()
"""
wsgi_req = uwsgi_pypy_current_wsgi_req()
ub = lib.uwsgi_websocket_recv_nb(wsgi_req)
if ub == ffi.NULL:
raise IOError("unable to receive websocket message")
ret = ffi.string(ub.buf, ub.pos)
@@ -867,11 +900,12 @@ def uwsgi_pypy_websocket_recv_nb():
return ret
uwsgi.websocket_recv_nb = uwsgi_pypy_websocket_recv_nb
"""
uwsgi.websocket_handshake(key, origin)
"""
def uwsgi_pypy_websocket_handshake(key='', origin='', proto=''):
wsgi_req = uwsgi_pypy_current_wsgi_req();
"""
uwsgi.websocket_handshake(key, origin)
"""
wsgi_req = uwsgi_pypy_current_wsgi_req()
c_key = ffi.new('char[]', key)
c_origin = ffi.new('char[]', origin)
c_proto = ffi.new('char[]', proto)
@@ -879,20 +913,22 @@ def uwsgi_pypy_websocket_handshake(key='', origin='', proto=''):
raise IOError("unable to complete websocket handshake")
uwsgi.websocket_handshake = uwsgi_pypy_websocket_handshake
"""
uwsgi.websocket_send(msg)
"""
def uwsgi_pypy_websocket_send(msg):
wsgi_req = uwsgi_pypy_current_wsgi_req();
"""
uwsgi.websocket_send(msg)
"""
wsgi_req = uwsgi_pypy_current_wsgi_req()
if lib.uwsgi_websocket_send(wsgi_req, ffi.new('char[]', msg), len(msg)) < 0:
raise IOError("unable to send websocket message")
uwsgi.websocket_send = uwsgi_pypy_websocket_send
"""
uwsgi.chunked_read(timeout=0)
"""
def uwsgi_pypy_chunked_read(timeout=0):
wsgi_req = uwsgi_pypy_current_wsgi_req();
"""
uwsgi.chunked_read(timeout=0)
"""
wsgi_req = uwsgi_pypy_current_wsgi_req()
rlen = ffi.new("size_t*")
chunk = lib.uwsgi_chunked_read(wsgi_req, rlen, timeout, 0)
if chunk == ffi.NULL:
@@ -900,25 +936,27 @@ def uwsgi_pypy_chunked_read(timeout=0):
return ffi.string(chunk, rlen[0])
uwsgi.chunked_read = uwsgi_pypy_chunked_read
"""
uwsgi.chunked_read_nb()
"""
def uwsgi_pypy_chunked_read_nb():
wsgi_req = uwsgi_pypy_current_wsgi_req();
"""
uwsgi.chunked_read_nb()
"""
wsgi_req = uwsgi_pypy_current_wsgi_req()
rlen = ffi.new("size_t*")
chunk = lib.uwsgi_chunked_read(wsgi_req, rlen, 0, 1)
if chunk == ffi.NULL:
if lib.uwsgi_is_again() > 0:
return None
raise IOError("unable to receive chunked part")
return ffi.string(chunk, rlen[0])
uwsgi.chunked_read_nb = uwsgi_pypy_chunked_read_nb
"""
uwsgi.set_user_harakiri(sec)
"""
def uwsgi_pypy_set_user_harakiri(x):
"""
uwsgi.set_user_harakiri(sec)
"""
wsgi_req = uwsgi_pypy_current_wsgi_req()
lib.set_user_harakiri(wsgi_req, x)
uwsgi.set_user_harakiri = uwsgi_pypy_set_user_harakiri
@@ -939,10 +977,11 @@ uwsgi_pypy_continulets = {}
def uwsgi_pypy_continulet_wrapper(cont):
lib.async_schedule_to_req_green()
@ffi.callback("void()")
def uwsgi_pypy_continulet_schedule():
id = lib.uwsgi.wsgi_req.async_id
modifier1 = lib.uwsgi.wsgi_req.uh.modifier1;
modifier1 = lib.uwsgi.wsgi_req.uh.modifier1
# generate a new continulet
if not lib.uwsgi.wsgi_req.suspended:
@@ -952,33 +991,35 @@ def uwsgi_pypy_continulet_schedule():
# this is called in the main stack
if lib.uwsgi.p[modifier1].suspend:
lib.uwsgi.p[modifier1].suspend(ffi.NULL)
lib.uwsgi.p[modifier1].suspend(ffi.NULL)
# let's switch
uwsgi_pypy_continulets[id].switch()
# back to the main stack
if lib.uwsgi.p[modifier1].resume:
lib.uwsgi.p[modifier1].resume(ffi.NULL)
lib.uwsgi.p[modifier1].resume(ffi.NULL)
@ffi.callback("void(struct wsgi_request *)")
def uwsgi_pypy_continulet_switch(wsgi_req):
id = wsgi_req.async_id
modifier1 = wsgi_req.uh.modifier1;
modifier1 = wsgi_req.uh.modifier1
# this is called in the current continulet
if lib.uwsgi.p[modifier1].suspend:
lib.uwsgi.p[modifier1].suspend(wsgi_req)
lib.uwsgi.p[modifier1].suspend(wsgi_req)
uwsgi_pypy_continulets[id].switch()
# back to the continulet
if lib.uwsgi.p[modifier1].resume:
lib.uwsgi.p[modifier1].resume(wsgi_req)
lib.uwsgi.p[modifier1].resume(wsgi_req)
# update current running continulet
lib.uwsgi.wsgi_req = wsgi_req
def uwsgi_pypy_setup_continulets():
if lib.uwsgi.async < 1:
raise Exception("pypy continulets require async mode !!!")
+6 -3
View File
@@ -1,11 +1,14 @@
NAME='pypy'
NAME = 'pypy'
LDFLAGS = []
LIBS = []
GCC_LIST = ['pypy_plugin']
BINARY_LIST = [ ('_uwsgi_pypy_setup','pypy_setup.py')]
BINARY_LIST = [
('_uwsgi_pypy_setup', 'pypy_setup.py'),
]
CFLAGS = []
try:
import __pypy__
import __pypy__ # NOQA
import sys
CFLAGS.append('-DUWSGI_PYPY_HOME="\\"%s\\""' % sys.prefix)
except:
+28 -8
View File
@@ -1,7 +1,9 @@
import os,sys
import os
import sys
from distutils import sysconfig
def get_python_version():
version = sysconfig.get_config_var('VERSION')
try:
@@ -10,13 +12,31 @@ def get_python_version():
pass
return version
NAME='python'
GCC_LIST = ['python_plugin', 'pyutils', 'pyloader', 'wsgi_handlers', 'wsgi_headers', 'wsgi_subhandler', 'web3_subhandler', 'pump_subhandler', 'gil', 'uwsgi_pymodule', 'profiler', 'symimporter', 'tracebacker', 'raw']
NAME = 'python'
GCC_LIST = [
'python_plugin',
'pyutils',
'pyloader',
'wsgi_handlers',
'wsgi_headers',
'wsgi_subhandler',
'web3_subhandler',
'pump_subhandler',
'gil',
'uwsgi_pymodule',
'profiler',
'symimporter',
'tracebacker',
'raw'
]
CFLAGS = ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True) ]
CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True),
]
LDFLAGS = []
if not 'UWSGI_PYTHON_NOLIB' in os.environ:
if 'UWSGI_PYTHON_NOLIB' not in os.environ:
LIBS = sysconfig.get_config_var('LIBS').split() + sysconfig.get_config_var('SYSLIBS').split()
# check if it is a non-shared build (but please, add --enable-shared to your python's ./configure script)
if not sysconfig.get_config_var('Py_ENABLE_SHARED'):
@@ -37,13 +57,13 @@ if not 'UWSGI_PYTHON_NOLIB' in os.environ:
uname = os.uname()
if uname[4].startswith('arm'):
libpath = '%s/%s' % (libdir, sysconfig.get_config_var('LIBRARY'))
if not os.path.exists(libpath):
if not os.path.exists(libpath):
libpath = '%s/%s' % (libdir, sysconfig.get_config_var('LDLIBRARY'))
else:
libpath = '%s/%s' % (libdir, sysconfig.get_config_var('LDLIBRARY'))
if not os.path.exists(libpath):
if not os.path.exists(libpath):
libpath = '%s/%s' % (libdir, sysconfig.get_config_var('LIBRARY'))
if not os.path.exists(libpath):
if not os.path.exists(libpath):
libpath = '%s/libpython%s.a' % (libdir, version)
LIBS.append(libpath)
# hack for messy linkers/compilers
+6 -2
View File
@@ -3,8 +3,12 @@ import os
os.environ['UWSGI_PYTHON_NOLIB'] = '1'
NAME='pyuwsgi'
CFLAGS = ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True)]
NAME = 'pyuwsgi'
CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True),
]
LDFLAGS = []
LIBS = []
+6 -7
View File
@@ -1,11 +1,11 @@
import os,sys
import os
NAME='rack'
NAME = 'rack'
try:
RUBYPATH = os.environ['UWSGICONFIG_RUBYPATH']
RUBYPATH = os.environ['UWSGICONFIG_RUBYPATH']
except:
RUBYPATH = 'ruby'
RUBYPATH = 'ruby'
rbconfig = 'Config'
@@ -18,7 +18,7 @@ if (v[0] == '1' and v[1] == '9') or v[0] >= '2':
CFLAGS = os.popen(RUBYPATH + " -e \"require 'rbconfig';print RbConfig::CONFIG['CFLAGS']\"").read().rstrip().split()
CFLAGS.append('-DRUBY19')
CFLAGS.append('-Wno-unused-parameter')
rbconfig = 'RbConfig'
rbconfig = 'RbConfig'
else:
CFLAGS = os.popen(RUBYPATH + " -e \"require 'rbconfig';print %s::CONFIG['CFLAGS']\"" % rbconfig).read().rstrip().split()
@@ -45,7 +45,7 @@ has_shared = os.popen(RUBYPATH + " -e \"require 'rbconfig';print %s::CONFIG['ENA
LIBS = os.popen(RUBYPATH + " -e \"require 'rbconfig';print %s::CONFIG['LIBS']\"" % rbconfig).read().rstrip().split()
if has_shared == 'yes':
LDFLAGS.append('-L' + libpath )
LDFLAGS.append('-L' + libpath)
os.environ['LD_RUN_PATH'] = libpath
LIBS.append(os.popen(RUBYPATH + " -e \"require 'rbconfig';print '-l' + %s::CONFIG['RUBY_SO_NAME']\"" % rbconfig).read().rstrip())
else:
@@ -64,4 +64,3 @@ else:
CFLAGS.append('-DUWSGI_RUBY_LIBDIR="\\"%s\\""' % rubylibdir)
CFLAGS.append('-DUWSGI_RUBY_ARCHDIR="\\"%s\\""' % rubyarchdir)
GCC_LIST.append("%s/%s" % (libpath, os.popen(RUBYPATH + " -e \"require 'rbconfig';print %s::CONFIG['LIBRUBY_A']\"" % rbconfig).read().rstrip()))
+1 -2
View File
@@ -1,5 +1,4 @@
import os
NAME='rados'
NAME = 'rados'
CFLAGS = []
LDFLAGS = []
+1 -1
View File
@@ -1,5 +1,5 @@
NAME = 'rawrouter'
NAME='rawrouter'
CFLAGS = []
LDFLAGS = []
LIBS = []
+1 -1
View File
@@ -1,6 +1,6 @@
import os
NAME='rbthreads'
NAME = 'rbthreads'
try:
RUBYPATH = os.environ['UWSGICONFIG_RUBYPATH']
+1 -1
View File
@@ -1,4 +1,4 @@
NAME='redislog'
NAME = 'redislog'
CFLAGS = []
LDFLAGS = []
+3 -2
View File
@@ -1,6 +1,8 @@
import os
import shutil
NAME = 'ring'
jvm_path = 'plugins/jvm'
up = {}
@@ -11,13 +13,13 @@ except:
exec(f.read(), up)
f.close()
NAME='ring'
CFLAGS = up['CFLAGS']
CFLAGS.append('-I%s' % jvm_path)
LDFLAGS = []
LIBS = []
GCC_LIST = ['ring_plugin']
def post_build(config):
env = os.environ.get('VIRTUAL_ENV')
if env:
@@ -26,4 +28,3 @@ def post_build(config):
tgt = "%s/bin/ring_plugin.so" % env
shutil.copyfile(plugin, tgt)
print("*** ring_plugin.so had been copied to %s" % tgt)
+2 -1
View File
@@ -1,4 +1,5 @@
NAME='router_access'
NAME = 'router_access'
CFLAGS = []
LDFLAGS = []
LIBS = ['-lwrap']
+2 -1
View File
@@ -1,5 +1,6 @@
import os
NAME='router_basicauth'
NAME = 'router_basicauth'
CFLAGS = []
LDFLAGS = []

Some files were not shown because too many files have changed in this diff Show More