kopia lustrzana https://github.com/cirospaciari/socketify.py
more WSGI stuff
rodzic
18892b729d
commit
e0e28263f5
|
@ -30,7 +30,31 @@ def app_hello(environ, start_response):
|
|||
yield b'Hello, World!'
|
||||
|
||||
if __name__ == "__main__":
|
||||
from socketify import WSGI
|
||||
WSGI(app_chunked).listen(8000, lambda config: print(f"Listening on port http://localhost:{config.port} now\n")).run(8)
|
||||
# import fastwsgi
|
||||
# fastwsgi.run(wsgi_app=app_hello, host='127.0.0.1', port=8000)
|
||||
# from meinheld import server
|
||||
# server.listen(("0.0.0.0", 8000))
|
||||
# server.run(app_hello)
|
||||
from socketify import WSGI
|
||||
WSGI(app_hello).listen(8000, lambda config: print(f"Listening on port http://localhost:{config.port} now\n")).run(1)
|
||||
# def run_app():
|
||||
# import fastwsgi
|
||||
# fastwsgi.run(wsgi_app=app_hello, host='127.0.0.1', port=8000)
|
||||
|
||||
# import os
|
||||
# pid_list = []
|
||||
# # fork limiting the cpu count - 1
|
||||
# for _ in range(1, 8):
|
||||
# pid = os.fork()
|
||||
# # n greater than 0 means parent process
|
||||
# if not pid > 0:
|
||||
# run_app()
|
||||
# break
|
||||
# pid_list.append(pid)
|
||||
|
||||
# run_app() # run app on the main process too :)
|
||||
|
||||
# # sigint everything to gracefull shutdown
|
||||
# import signal
|
||||
# for pid in pid_list:
|
||||
# os.kill(pid, signal.SIGINT)
|
||||
|
|
|
@ -29,7 +29,7 @@ def create_fork():
|
|||
|
||||
|
||||
# fork limiting the cpu count - 1
|
||||
for i in range(1, multiprocessing.cpu_count()):
|
||||
create_fork()
|
||||
# for i in range(1, multiprocessing.cpu_count()):
|
||||
# create_fork()
|
||||
|
||||
run_app() # run app on the main process too :)
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
# using oha -c 400 -z 5s http://localhost:3000/
|
||||
|
||||
# nginx - try_files - 77630.15 req/s
|
||||
# pypy3 - socketify static - 15839.22 req/s
|
||||
# python3 - socketify static - 8294.96 req/s
|
||||
# pypy3 - socketify static - 16797.30 req/s
|
||||
# python3 - socketify static - 10140.19 req/s
|
||||
# node.js - @fastify/static - 5437.16 req/s
|
||||
# node.js - express.static - 4077.49 req/s
|
||||
# python3 - socketify static_aiofile - 2390.96 req/s
|
||||
|
|
|
@ -222,7 +222,7 @@ def async_middleware(*functions):
|
|||
class DecoratorRouter:
|
||||
def __init__(self, app, prefix: str = "", *middlewares):
|
||||
self.app = app
|
||||
self.middlewares = list(middlewares)
|
||||
self.middlewares = list(*middlewares)
|
||||
self.prefix = prefix
|
||||
|
||||
def get(self, path):
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit f5a4235d2751c07d3f834ad86f42c2cab59eded0
|
||||
Subproject commit 216c8b9ea20ec8719175b136cf86cb51b316382d
|
|
@ -323,6 +323,7 @@ def wsgi(ssl, response, info, user_data, aborted):
|
|||
# no content-length
|
||||
if content_length < 0:
|
||||
is_chunked = True
|
||||
content_length = ffi.cast("uintmax_t", content_length)
|
||||
|
||||
def start_response(status, headers, exc_info=None):
|
||||
nonlocal headers_set, status_text
|
||||
|
@ -355,7 +356,7 @@ def wsgi(ssl, response, info, user_data, aborted):
|
|||
return write
|
||||
|
||||
failed_chunks = None
|
||||
content_length = ffi.cast("uintmax_t", content_length)
|
||||
|
||||
last_offset = -1
|
||||
data_retry = None
|
||||
# check for body
|
||||
|
@ -379,6 +380,8 @@ def wsgi(ssl, response, info, user_data, aborted):
|
|||
if data:
|
||||
if not headers_written:
|
||||
write_headers(headers_set)
|
||||
content_length = ffi.cast("uintmax_t", content_length)
|
||||
|
||||
if is_chunked:
|
||||
if isinstance(data, bytes):
|
||||
lib.uws_res_write(ssl, response, data, len(data))
|
||||
|
|
Ładowanie…
Reference in New Issue