jonashaag / bjoern Goto Github PK
View Code? Open in Web Editor NEWA screamingly fast Python 2/3 WSGI server written in C.
License: Other
A screamingly fast Python 2/3 WSGI server written in C.
License: Other
Does bjoern work with gevent? I want to migrate my WSGI app powered by gunicorn (gevent worker) to bjoern. I am using gevent API (spawn, Pool, monkey patch) in our app too.
Is it possible?
thatoneguy@thebadpipsissewah:/bjoern$ python ./setup.py build/bjoern$ ls http-parser/
running build
running build_ext
building 'bjoern' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/http-parser
creating build/temp.linux-x86_64-2.7/bjoern
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_SENDFILE=1 -DWANT_SIGINT_HANDLING=1 -Ihttp-parser -I/usr/include/python2.7 -c http-parser/http_parser.c -o build/temp.linux-x86_64-2.7/http-parser/http_parser.o -std=c99 -fno-strict-aliasing -fcommon -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -g
x86_64-linux-gnu-gcc: error: http-parser/http_parser.c: No such file or directory
x86_64-linux-gnu-gcc: fatal error: no input files
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 4
thatoneguy@thebadpipsissewah:
thatoneguy@thebadpipsissewah:~/bjoern$
commit c79d7b1
Author: Jonas Haag [email protected]
Date: Fri Jun 7 01:14:14 2013 +0200
Version 1.3.2
Could you include some benchmarks in https://github.com/TechEmpower/FrameworkBenchmarks?
http://www.techempower.com/benchmarks/#section=code&hw=peak&test=query
if someone else volunteers to do this just ask me about it :)
When running tests/hello.py
two requests succeed and the third segfaults. Reverting to 772d resolves the issue on my system.
How is bjoern performing comparing to uwsgi?
Both of them are written in C.
What are the differences?
Testing with apachebench and curl; verbose output from curl, which you can see tries to reuse the connection:
curl -v http://192.168.1.190:8081 http://192.168.1.190:8081
* About to connect() to 192.168.1.190 port 8081 (#0)
* Trying 192.168.1.190... connected
> GET / HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-unknown-linux-gnu) libcurl/7.22.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
> Host: 192.168.1.190:8081
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-type: text/plain
< Content-Length: 5
<
* Connection #0 to host 192.168.1.190 left intact
* Connection #0 seems to be dead!
* Closing connection #0
* About to connect() to 192.168.1.190 port 8081 (#0)
* Trying 192.168.1.190... connected
> GET / HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-unknown-linux-gnu) libcurl/7.22.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
> Host: 192.168.1.190:8081
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-type: text/plain
< Content-Length: 5
<
* Connection #0 to host 192.168.1.190 left intact
* Closing connection #0
Pong!Pong
Note the 'connection seems to be dead' line, and that the content of two responses seems to come all at once at the end ("Pong!Pong!"), rather than displayed inline with the request as Curl would normally do.
apachebench with -k flag will just hang after making a connection (presumably after the first request is served).
Here's my test app:
#!/usr/bin/python
import bjoern
def application(environ, start_response):
status = '200 OK'
output = 'Pong!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
bjoern.run(application, '192.168.1.190', 8081)
Testing with the latest code base.
Worth noting that Curl does not pipeline requests, it's waiting for the response before sending the second request.
Would it be difficult to include a REQUEST_IP
key in the request
dictionary? Is there already an obvious method of obtaining this information?
Hello Jonas, all fine?
I installed the web server with http-parser and libev using setup.py but when I run the simple listen.py and try to see in the browser I receber infinity wait, just loading forever.
Python 2.7.1+, Ubunto 10.04
Cya!
Will need to figure out where to stick that close
method. I'd like to avoid adding another Request
struct member.
Hello!
Im try setup bjoern on Python3
$ python3 -V
Python 3.1.3
$ python3 setup.py build
:
In file included from bjoern/common.h:11,
from bjoern/common.c:1:
bjoern/25compat.h:5:1: warning: "PyVarObject_HEAD_INIT" redefined
In file included from /usr/include/python3.1/Python.h:64,
from bjoern/common.h:4,
from bjoern/common.c:1:
/usr/include/python3.1/object.h:84:1: warning: this is the location of the previous definition
.....
:
bjoern/request.c:2:23: error: cStringIO.h: No such file or directory
In file included from bjoern/common.h:11,
from bjoern/request.h:6,
from bjoern/request.c:3:
$ find /usr/include -name cStringIO.h
/usr/include/python2.7/cStringIO.h
Found v2.7 only. What to do with v3.x?
I'm wondering if there is a way to conveniently start a few processes that can serve requests together. For testing so far I manually create a dozen of sockets and put them in my nginx config.
Since that is working like a charm I'm considering switching to bjoern from gunicorn. I don't need most of the options and features gunicorn offers, but I like how it spawns a number of processes that share a socket.
I'm happy to implement it myself if a feature like that doesn't exist yet, but I wanted to make sure I'm not missing something that's already out there. So far I haven't found anything...
Python 2.7, latest Snow Leopard, libev 3.9 installed via ports. Installed via:
sudo port install libev
virtualenv --no-site-packages --distribute sandbox
cd sandbox ; . bin/activate
pip install bjoern
The result is that ev.h can't be found and thus a whole slew of errors and warnings are displayed. The version of Python, operating system, and the exact errors/warnings I believe are irrelevant to this problem; ports likely installed libev in /usr/local instead of /usr.
How would I tell pip (or, if I clone the repo, setup.py) to check a different location for includes/libraries?
Right now Bjoern does not seem to have any logging capability. It would be nice to provide an option (or a callback) to do it. Alternatively, I guess the option is to use a logging middleware.
hi,when I test app on the bjoern server,console displays below errors
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/Flask-0.8-py2.6.egg/flask/app.py", line 1506, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.6/dist-packages/Flask-0.8-py2.6.egg/flask/app.py", line 1504, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.6/dist-packages/Flask-0.8-py2.6.egg/flask/app.py", line 1264, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.6/dist-packages/Flask-0.8-py2.6.egg/flask/app.py", line 1262, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.6/dist-packages/Flask-0.8-py2.6.egg/flask/app.py", line 1248, in dispatch_request
return self.view_functionsrule.endpoint
File "/usr/local/lib/python2.6/dist-packages/Flask-0.8-py2.6.egg/flask/helpers.py", line 623, in send_static_file
return send_from_directory(self.static_folder, filename)
File "/usr/local/lib/python2.6/dist-packages/Flask-0.8-py2.6.egg/flask/helpers.py", line 473, in send_from_directory
return send_file(filename, conditional=True, **options)
File "/usr/local/lib/python2.6/dist-packages/Flask-0.8-py2.6.egg/flask/helpers.py", line 385, in send_file
data = wrap_file(request.environ, file)
File "/usr/local/lib/python2.6/dist-packages/Werkzeug-0.8.3-py2.6.egg/werkzeug/wsgi.py", line 536, in wrap_file
return environ.get('wsgi.file_wrapper', FileWrapper)(file, buffer_size)
TypeError: FileWrapper() takes exactly 1 argument (2 given)
running install
running build
running build_py
running build_ext
building '_bjoern' extension
i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_SENDFILE=1 -DWANT_SIGINT_HANDLING=1 -Ihttp-parser -I/usr/include/libev -I/usr/include/python2.7 -c http-parser/http_parser.c -o build/temp.linux-i686-2.7/http-parser/http_parser.o -std=c99 -fno-strict-aliasing -fcommon -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -g
i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_SENDFILE=1 -DWANT_SIGINT_HANDLING=1 -Ihttp-parser -I/usr/include/libev -I/usr/include/python2.7 -c bjoern/portable_sendfile.c -o build/temp.linux-i686-2.7/bjoern/portable_sendfile.o -std=c99 -fno-strict-aliasing -fcommon -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -g
In file included from bjoern/portable_sendfile.c:3:0:
bjoern/portable_sendfile.h:1:41: fatal error: Python.h: No such file or directory
#include <Python.h> /* for Py_ssize_t */
^
compilation terminated.
error: command 'i686-linux-gnu-gcc' failed with exit status 1
Arch Linux Python 2.7.6 generates an ImportError for the bjoern module:
Python 2.7.6 (default, Feb 26 2014, 12:07:17)
[GCC 4.8.2 20140206 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bjoern
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initbjoern)
Any clues?
Thanks!
Under Python 2.5, compiling bjoern fails with errors like:
src/wsgi_sendfile.c: In function ‘wsgi_sendfile_init’: src/wsgi_sendfile.c:6: warning: implicit declaration of function ‘PyFile_IncUseCount’ src/wsgi_sendfile.c: In function ‘wsgi_sendfile’: src/wsgi_sendfile.c:85: warning: implicit declaration of function ‘PyFile_DecUseCount’ src/wsgi_sendfile.c:86: warning: dereferencing ‘void *’ pointer src/wsgi_sendfile.c:86: error: request for member ‘ob_refcnt’ in something not a structure or union
Could we fix this?
The example on how to fork server process on multiple core servers. However, is there any way to gracefully stop and restart server processes?
It would be great if test cases for this feature are added
Thanks
$ pip install bjoern
my system is centos python2.6.5
/usr/local/bin/pip run on Sun Feb 12 17:10:46 2012
Downloading/unpacking bjoern
Running setup.py egg_info for package bjoern
running egg_info
writing pip-egg-info/bjoern.egg-info/PKG-INFO
writing top-level names to pip-egg-info/bjoern.egg-info/top_level.txt
writing dependency_links to pip-egg-info/bjoern.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/bjoern.egg-info/SOURCES.txt'
writing manifest file 'pip-egg-info/bjoern.egg-info/SOURCES.txt'
Installing collected packages: bjoern
Running setup.py install for bjoern
Running command /usr/local/bin/python -c "import setuptools;__file__='/root/build/bjoern/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single
-version-externally-managed --record /tmp/pip-SNmVtv-record/install-record.txt
running install
running build
running build_ext
building 'bjoern' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWANT_SENDFILE=1 -DWANT_SIGINT_HANDLING=1 -Ihttp-parser -I/usr/local/include/python2.6 -c http-parser/
http_parser.c -o build/temp.linux-x86_64-2.6/http-parser/http_parser.o -std=c99 -fno-strict-aliasing -Wall -Wextra -Wno-unused -g -fPIC
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWANT_SENDFILE=1 -DWANT_SIGINT_HANDLING=1 -Ihttp-parser -I/usr/local/include/python2.6 -c bjoern/wsgi.
c -o build/temp.linux-x86_64-2.6/bjoern/wsgi.o -std=c99 -fno-strict-aliasing -Wall -Wextra -Wno-unused -g -fPIC
In file included from bjoern/wsgi.c:1:
bjoern/common.h:24: warning: function declaration isn’t a prototype
In file included from bjoern/wsgi.c:3:
bjoern/filewrapper.h:12: warning: function declaration isn’t a prototype
In file included from bjoern/wsgi.h:2,
from bjoern/wsgi.c:4:
bjoern/request.h:4:16: error: ev.h: No such file or directory
In file included from bjoern/wsgi.h:2,
from bjoern/wsgi.c:4:
bjoern/request.h:33: error: expected specifier-qualifier-list before ‘ev_io’
bjoern/wsgi.c: In function ‘wsgi_call_application’:
bjoern/wsgi.c:24: error: ‘Request’ has no member named ‘headers’
bjoern/wsgi.c:25: error: ‘Request’ has no member named ‘headers’
bjoern/wsgi.c:89: error: ‘Request’ has no member named ‘state’
bjoern/wsgi.c:90: error: ‘Request’ has no member named ‘iterable’
bjoern/wsgi.c:91: error: ‘Request’ has no member named ‘iterable’
bjoern/wsgi.c:93: error: ‘Request’ has no member named ‘iterator’
bjoern/wsgi.c:97: error: ‘Request’ has no member named ‘iterable’
bjoern/wsgi.c:98: error: ‘Request’ has no member named ‘iterator’
bjoern/wsgi.c:99: error: ‘Request’ has no member named ‘iterator’
bjoern/wsgi.c:106: error: ‘Request’ has no member named ‘headers’
bjoern/wsgi.c:120: error: ‘Request’ has no member named ‘state’
bjoern/wsgi.c:120: error: ‘Request’ has no member named ‘state’
bjoern/wsgi.c:121: error: ‘Request’ has no member named ‘state’
bjoern/wsgi.c:123: error: ‘Request’ has no member named ‘state’
bjoern/wsgi.c:145: error: ‘Request’ has no member named ‘state’
bjoern/wsgi.c:160: error: ‘Request’ has no member named ‘state’
bjoern/wsgi.c:161: error: ‘Request’ has no member named ‘current_chunk’
bjoern/wsgi.c:162: error: ‘Request’ has no member named ‘current_chunk_p’
bjoern/wsgi.c: In function ‘inspect_headers’:
bjoern/wsgi.c:172: error: ‘Request’ has no member named ‘headers’
bjoern/wsgi.c:173: error: ‘Request’ has no member named ‘headers’
bjoern/wsgi.c:185: error: ‘Request’ has no member named ‘state’
bjoern/wsgi.c:190: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘Py_ssize_t’
bjoern/wsgi.c: In function ‘wsgi_getheaders’:
bjoern/wsgi.c:209: error: ‘Request’ has no member named ‘status’
Hi, I'm having trouble trying out bjoern for an existing web app that currently runs on a threaded server. The problem is the app uses thread.local to store state during a request. Since bjoern is single threaded this fails non-deterministically even for small number of concurrent requests. gevent is also single threaded but seems to get around this issue by monkey patching thread.local (among several others). Is there (going to be) similar support in bjoern?
According to CGI/1.1, environ PATH_INFO
should be unquoted
Hi,
I am getting the following error message and would like to be able to install bjoern. I am trying to install it on a Webfaction server so don't have write access to everythin.
thanks,
Ken Dere
$ pip -v install bjoern
Downloading/unpacking bjoern
Running setup.py egg_info for package bjoern
running egg_info
writing pip-egg-info/bjoern.egg-info/PKG-INFO
writing top-level names to pip-egg-info/bjoern.egg-info/top_level.txt
writing dependency_links to pip-egg-info/bjoern.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/bjoern.egg-info/SOURCES.txt'
writing manifest file 'pip-egg-info/bjoern.egg-info/SOURCES.txt'
Installing collected packages: bjoern
Running setup.py install for bjoern
running install
running build
running build_ext
building 'bjoern' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/home/kdere/include -fPIC -DWANT_SENDFILE=1 -DWANT_SIGINT_HANDLING=1 -Ihttp-parser -I/usr/local/include/python2.5 -c bjoern/wsgi.c -o build/temp.linux-i686-2.5/bjoern/wsgi.o -std=c99 -fno-strict-aliasing -Wall -Wextra -Wno-unused -g -fPIC
In file included from bjoern/wsgi.c:1:
bjoern/common.h:13: warning: function declaration isn’t a prototype
In file included from bjoern/wsgi.c:3:
bjoern/wsgi.h:4: warning: function declaration isn’t a prototype
bjoern/wsgi.c: In function ‘inspect_headers’:
bjoern/wsgi.c:188: warning: implicit declaration of function ‘Py_TYPE’
bjoern/wsgi.c:188: error: invalid type argument of ‘->’
bjoern/wsgi.c: At top level:
bjoern/wsgi.h:6: warning: ‘wsgi_iterable_get_next_chunk’ declared inline after being called
bjoern/wsgi.h:6: warning: previous declaration of ‘wsgi_iterable_get_next_chunk’ was here
bjoern/wsgi.c: In function ‘wsgi_iterable_get_next_chunk’:
bjoern/wsgi.c:236: error: invalid type argument of ‘->’
bjoern/wsgi.c: In function ‘start_response’:
bjoern/wsgi.c:282: error: invalid type argument of ‘->’
bjoern/wsgi.c:305: error: invalid type argument of ‘->’
bjoern/wsgi.c:309: error: invalid type argument of ‘->’
bjoern/wsgi.c: At top level:
bjoern/wsgi.c:339: warning: missing initializer
bjoern/wsgi.c:339: warning: (near initialization for ‘StartResponse_Type.tp_str’)
bjoern/wsgi.c:383: warning: function declaration isn’t a prototype
error: command 'gcc' failed with exit status 1
Complete output from command /usr/local/bin/python2.5 -c "import setuptools;file='/home/kdere/build/bjoern/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record /tmp/pip-6G5FIb-record/install-record.txt:
running install
running build
running build_ext
building 'bjoern' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/home/kdere/include -fPIC -DWANT_SENDFILE=1 -DWANT_SIGINT_HANDLING=1 -Ihttp-parser -I/usr/local/include/python2.5 -c bjoern/wsgi.c -o build/temp.linux-i686-2.5/bjoern/wsgi.o -std=c99 -fno-strict-aliasing -Wall -Wextra -Wno-unused -g -fPIC
In file included from bjoern/wsgi.c:1:
bjoern/common.h:13: warning: function declaration isn’t a prototype
In file included from bjoern/wsgi.c:3:
bjoern/wsgi.h:4: warning: function declaration isn’t a prototype
bjoern/wsgi.c: In function ‘inspect_headers’:
bjoern/wsgi.c:188: warning: implicit declaration of function ‘Py_TYPE’
bjoern/wsgi.c:188: error: invalid type argument of ‘->’
bjoern/wsgi.c: At top level:
bjoern/wsgi.h:6: warning: ‘wsgi_iterable_get_next_chunk’ declared inline after being called
bjoern/wsgi.h:6: warning: previous declaration of ‘wsgi_iterable_get_next_chunk’ was here
bjoern/wsgi.c: In function ‘wsgi_iterable_get_next_chunk’:
bjoern/wsgi.c:236: error: invalid type argument of ‘->’
bjoern/wsgi.c: In function ‘start_response’:
bjoern/wsgi.c:282: error: invalid type argument of ‘->’
bjoern/wsgi.c:305: error: invalid type argument of ‘->’
bjoern/wsgi.c:309: error: invalid type argument of ‘->’
bjoern/wsgi.c: At top level:
bjoern/wsgi.c:339: warning: missing initializer
bjoern/wsgi.c:339: warning: (near initialization for ‘StartResponse_Type.tp_str’)
bjoern/wsgi.c:383: warning: function declaration isn’t a prototype
error: command 'gcc' failed with exit status 1
Command /usr/local/bin/python2.5 -c "import setuptools;file='/home/kdere/build/bjoern/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record /tmp/pip-6G5FIb-record/install-record.txt failed with error code 1
Exception information:
Traceback (most recent call last):
File "/home/kdere/lib/python2.5/pip-1.0-py2.5.egg/pip/basecommand.py", line 126, in main
self.run(options, args)
File "/home/kdere/lib/python2.5/pip-1.0-py2.5.egg/pip/commands/install.py", line 228, in run
requirement_set.install(install_options, global_options)
File "/home/kdere/lib/python2.5/pip-1.0-py2.5.egg/pip/req.py", line 1093, in install
requirement.install(install_options, global_options)
File "/home/kdere/lib/python2.5/pip-1.0-py2.5.egg/pip/req.py", line 566, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "/home/kdere/lib/python2.5/pip-1.0-py2.5.egg/pip/init.py", line 255, in call_subprocess
% (command_desc, proc.returncode))
InstallationError: Command /usr/local/bin/python2.5 -c "import setuptools;file='/home/kdere/build/bjoern/setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --single-version-externally-managed --record /tmp/pip-6G5FIb-record/install-record.txt failed with error code 1
thanks
and can it serve static files too as fapws?
The type signature for for the on_path
function in bjoern.c
is supposed to take the path as a const char *
to match the function signature that http-parser expects, but actually takes a char *
. Right now there's actually a compiler warning when building bjoern about this. The function on_path
actually mutates the data pointed to by the path
pointer, since it unquotes in place.
I think the right thing here to do is actually to not URL unquote at all. In my testing of a handful of other WSGI servers, none of them automatically unquoted URLs; I guess the expectation is that whatever WSGI framework you're using will do the unquoting, not the WSGI server itself. So not only is this unquoting thing unhygienic for violating constness, it actually makes bjoern generally incompatible with most other WSGI frameworks. I'm happy to provide a patch to just remove the URL unquoting code if you agree.
for _ in xrange(NUM_WORKERS):
pid = os.fork()
if pid > 0:
# in master
worker_pids.append(pid)
elif pid == 0:
# in worker
try:
bjoern.run()
except KeyboardInterrupt:
pass
exit()
try:
for _ in xrange(NUM_WORKERS):
os.wait()
except KeyboardInterrupt:
for pid in worker_pids:
os.kill(pid, signal.SIGINT)
when I send KeyboardInterrupt signal by ctrl+c or kill -2 pid, the sever could not stop all the process.
cc -I/usr/include/python3.1 -I/usr/include/python3.1 -I . -I bjoern -I http-parser -D WANT_SENDFILE -D WANT_SIGINT_HANDLING -std=c99 -fno-strict-aliasing -Wall -Wextra -Wno-unused -g -O3 -fPIC -c bjoern/bjoernmodule.c -o build/bjoernmodule.o
In file included from bjoern/server.h:1:0,
from bjoern/bjoernmodule.c:2:
bjoern/request.h:4:16: fatal error: ev.h: No such file or directory
compilation terminated.
make: *** [build/bjoernmodule.o] Error 1
This is against HEAD (2010-12-24 18:58 UTC).
gcc version 4.5.1 20101125
Python version 2.7.1
Any thougths?
Interestingly enough, a fresh install still produces errors. The process:
The pip.log is: http://dpaste.de/wDGo/
Again it seems like I'm dealing with architecture (x86 vs. x64) issues. I'll have to see if there's a way to make brew install universal (dual 32-bit and 64-bit) versions.
I'm unsure whether bjoern logs requests and errors to
standard output and standard error. This information is
handy to server administrators. Could you please
shed some light on whether it does and how one can
access logs?
I don't really speak C, so I couldn't figure out if and how I could make bjoern not use sendfile. I need to conditionally prevent it from using sendfile (if it's using it at all) to prevent weird caching behavior in VirtualBox (see here for more information).
"sometimes" in my wsgi application environ i get only part of query string, that was send to server. Can't see any logic here, sometimes i got all, sometimes only partf of it. Any ideas how to fix that?
I trid to build this server from source on my FreeBSD8.2 system, but found a problem make this impossible.
Error happened in the "server.c" file.
Because BSD use libc as default, so the <sys/sendfile.h> include will go wrong( this file is a linux feature by glibc).
In BSD,there is a sendfile() function works just the same as in the Linux but has few more parameters.
The do_sendfile() function wrapped the sendfile() function in your code, so I think this make its easier to port to BSD.
Thanks for your excellent job!!
Line 62 in a090b0b
ev_signal_on_sigint(struct ev_loop* mainloop, ev_signal* watcher, const int events)
{
/* Clean up and shut down this thread.
* (Shuts down the Python interpreter if this is the main thread) */
ev_unloop(mainloop, EVUNLOOP_ALL);
PyErr_SetInterrupt();
}
This code bluntly interrupts request in processing. What is needed for graceful stop is ability to wait for current request to complete and only then raise exception or exit process.
Hi,
bjoern builds correctly on ARM, except for one warning, which is important:
bjoern/common.c:18:7: warning: comparison is always false due to limited range of data type [-Wtype-limits]
The reason is that (-1) in the NOHEX macro is interpreted as int
by the compiler, not as char
.
A simple fix would be to replace line 6 of common.c with
#define NOHEX ((char) -1)
which also makes the code slightly easier to read.
I guess a Pull Request is too much hassle for a one-liner, hence an Issue.
Cheers!
Hello,
bjoern compiled fine on ubuntu 9.10 but trying hello.py produced the following error.
python2.7: ev.c:2460: ev_signal_start: Assertion `("libev: signal watchers are only supported in the default loop", loop == ev_default_loop_ptr)' failed.
Aborted
Good effort starting this project. Would like to see it work out.
J
Hi,
bjoern has its own event loop to accept client connection in a non-blocking mode. I believe that bjoern and Tornado work in the same way in this regard.
However, Tornado provides developers with a callback-based programming model to integrate I/O ops happening in request handler with Tornado event loop. Therefore, I/O ops in request handlers can work in non-blocking mode without blocking Tornado's event loop when it runs.
I don't understand how it works in bjoern. For example, if I use urllib.open
against an URL, how can I register the newly opened socket with bjoern event loop. The same concern are database connection (TCP socket), UDP socket, regular file (open, write), stdout, stdin , ... thread joins ...
PS: I used Tornado to power my company API server 3 years ago. If our database connection socket is not registered with Tornado event loop, it will block the Tornado process. No incoming request can be handled
Leaks empty strings
Not in all cases, but in most (depends on whether the former call created a new reference)
Issue #11 doesn't seem to be fixed for me. I think I'm doing everything right:
brew install libev
mkvirtualenv bjoern
pip install bjoern
Full contents of pip.log below:
------------------------------------------------------------
/Users/jamie/.virtualenvs/bjoern/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg/pip/runner.py run on Wed Dec 29 16:55:59 2010
Downloading/unpacking bjoern
Running setup.py egg_info for package bjoern
running egg_info
writing pip-egg-info/bjoern.egg-info/PKG-INFO
writing top-level names to pip-egg-info/bjoern.egg-info/top_level.txt
writing dependency_links to pip-egg-info/bjoern.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/bjoern.egg-info/SOURCES.txt'
writing manifest file 'pip-egg-info/bjoern.egg-info/SOURCES.txt'
Installing collected packages: bjoern
Running setup.py install for bjoern
Running command /Users/jamie/.virtualenvs/bjoern/bin/python -c "import setuptools;__file__='/Users/jamie/.virtualenvs/bjoern/build/bjoern/setup.py';execfile(__file__)" install --single-version-externally-managed --record /var/folders/jT/jTsZ5I2lHYODq98s5pizV++++TI/-Tmp-/pip-guk8Dz-record/install-record.txt --install-headers /Users/jamie/.virtualenvs/bjoern/bin/../include/site/python2.6
running install
running build
running build_ext
building 'bjoern' extension
gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc -arch x86_64 build/temp.macosx-10.6-universal-2.6/http-parser/http_parser.o build/temp.macosx-10.6-universal-2.6/bjoern/request.o build/temp.macosx-10.6-universal-2.6/bjoern/bjoernmodule.o build/temp.macosx-10.6-universal-2.6/bjoern/server.o build/temp.macosx-10.6-universal-2.6/bjoern/wsgi.o -lev -o build/lib.macosx-10.6-universal-2.6/bjoern.so
ld: warning: in /usr/local/lib/libev.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: duplicate symbol _StartResponse_Type in build/temp.macosx-10.6-universal-2.6/bjoern/server.o and build/temp.macosx-10.6-universal-2.6/bjoern/bjoernmodule.o for architecture i386
collect2: ld returned 1 exit status
ld: warning: in /usr/local/lib/libev.dylib, file was built for unsupported file format which is not the architecture being linked (ppc)
ld: duplicate symbol _StartResponse_Type in build/temp.macosx-10.6-universal-2.6/bjoern/server.o and build/temp.macosx-10.6-universal-2.6/bjoern/bjoernmodule.o for architecture ppc
collect2: ld returned 1 exit status
ld: duplicate symbol _StartResponse_Type in build/temp.macosx-10.6-universal-2.6/bjoern/server.o and build/temp.macosx-10.6-universal-2.6/bjoern/bjoernmodule.o for architecture x86_64
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/jT/jTsZ5I2lHYODq98s5pizV++++TI/-Tmp-//cchfuOFY.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
Complete output from command /Users/jamie/.virtualenvs/bjoern/bin/python -c "import setuptools;__file__='/Users/jamie/.virtualenvs/bjoern/build/bjoern/setup.py';execfile(__file__)" install --single-version-externally-managed --record /var/folders/jT/jTsZ5I2lHYODq98s5pizV++++TI/-Tmp-/pip-guk8Dz-record/install-record.txt --install-headers /Users/jamie/.virtualenvs/bjoern/bin/../include/site/python2.6:
running install
running build
running build_ext
building 'bjoern' extension
gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc -arch x86_64 build/temp.macosx-10.6-universal-2.6/http-parser/http_parser.o build/temp.macosx-10.6-universal-2.6/bjoern/request.o build/temp.macosx-10.6-universal-2.6/bjoern/bjoernmodule.o build/temp.macosx-10.6-universal-2.6/bjoern/server.o build/temp.macosx-10.6-universal-2.6/bjoern/wsgi.o -lev -o build/lib.macosx-10.6-universal-2.6/bjoern.so
ld: warning: in /usr/local/lib/libev.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: duplicate symbol _StartResponse_Type in build/temp.macosx-10.6-universal-2.6/bjoern/server.o and build/temp.macosx-10.6-universal-2.6/bjoern/bjoernmodule.o for architecture i386
collect2: ld returned 1 exit status
ld: warning: in /usr/local/lib/libev.dylib, file was built for unsupported file format which is not the architecture being linked (ppc)
ld: duplicate symbol _StartResponse_Type in build/temp.macosx-10.6-universal-2.6/bjoern/server.o and build/temp.macosx-10.6-universal-2.6/bjoern/bjoernmodule.o for architecture ppc
collect2: ld returned 1 exit status
ld: duplicate symbol _StartResponse_Type in build/temp.macosx-10.6-universal-2.6/bjoern/server.o and build/temp.macosx-10.6-universal-2.6/bjoern/bjoernmodule.o for architecture x86_64
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/jT/jTsZ5I2lHYODq98s5pizV++++TI/-Tmp-//cchfuOFY.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
----------------------------------------
Command /Users/jamie/.virtualenvs/bjoern/bin/python -c "import setuptools;__file__='/Users/jamie/.virtualenvs/bjoern/build/bjoern/setup.py';execfile(__file__)" install --single-version-externally-managed --record /var/folders/jT/jTsZ5I2lHYODq98s5pizV++++TI/-Tmp-/pip-guk8Dz-record/install-record.txt --install-headers /Users/jamie/.virtualenvs/bjoern/bin/../include/site/python2.6 failed with error code 1
Exception information:
Traceback (most recent call last):
File "/Users/jamie/.virtualenvs/bjoern/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg/pip/basecommand.py", line 130, in main
self.run(options, args)
File "/Users/jamie/.virtualenvs/bjoern/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg/pip/commands/install.py", line 228, in run
requirement_set.install(install_options, global_options)
File "/Users/jamie/.virtualenvs/bjoern/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg/pip/req.py", line 1043, in install
requirement.install(install_options, global_options)
File "/Users/jamie/.virtualenvs/bjoern/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg/pip/req.py", line 559, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "/Users/jamie/.virtualenvs/bjoern/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg/pip/__init__.py", line 249, in call_subprocess
% (command_desc, proc.returncode))
InstallationError: Command /Users/jamie/.virtualenvs/bjoern/bin/python -c "import setuptools;__file__='/Users/jamie/.virtualenvs/bjoern/build/bjoern/setup.py';execfile(__file__)" install --single-version-externally-managed --record /var/folders/jT/jTsZ5I2lHYODq98s5pizV++++TI/-Tmp-/pip-guk8Dz-record/install-record.txt --install-headers /Users/jamie/.virtualenvs/bjoern/bin/../include/site/python2.6 failed with error code 1
The requirement for libev is important; and missing on my Snow Leopard install. There is a separate issue (resolved) about bjoern failing to compile on kubuntu (#4, "failed to compile").
Cloning the repository with the submodules doesn't work.
$ git clone --recursive [email protected]:gorakhargosh/bjoern.git
Cloning into bjoern...
remote: Counting objects: 1268, done.
remote: Compressing objects: 100% (512/512), done.
remote: Total 1268 (delta 808), reused 1148 (delta 737)
Receiving objects: 100% (1268/1268), 215.80 KiB | 67 KiB/s, done.
Resolving deltas: 100% (808/808), done.
Submodule 'http-parser' (git://github.com/ry/http-parser) registered for path 'http-parser'
Cloning into http-parser...
remote: Counting objects: 664, done.
remote: Compressing objects: 100% (248/248), done.
remote: Total 664 (delta 447), reused 619 (delta 413)
Receiving objects: 100% (664/664), 156.09 KiB | 75 KiB/s, done.
Resolving deltas: 100% (447/447), done.
fatal: reference is not a tree: 5338fbd4f2a5ac9b8478d9f5fad8f125e6ae4236
Unable to checkout '5338fbd4f2a5ac9b8478d9f5fad8f125e6ae4236' in submodule path 'http-parser'
hello, i use bjoern but i just run it from a python file with a "&" at the end -
is there a way to set it up as a system service, so i can have something like monit or watchdog restart it if it fails?
thank you,
greg
They removed the path and query callbacks and added a URL parsing utility instead.
I have some issues running bjoern with bottle.py:
File "..../lib/bottle.py", line 754, in wsgi start_response('500 INTERNAL SERVER ERROR', [('Content-Type', 'text/html')]) File "/usr/lib/python2.7/site-packages/beaker/middleware.py", line 151, in session_start_response return start_response(status, headers, exc_info) TypeError: start_response argument 3 must be a 3-tuple (got 'NoneType' object instead)
I'am not sure if its a problem in bottle.py or your server, even so this workaround fix the issue: http://ramit.in/260d971a85_nl.html
First of all thanks for such great working WSGI server. I ran a couple of benchmarks using ab against tornado, gevent and gunicorn. And it definitely makes them bite the dust. I am impressed. But what follows is my installations issue. Though i have got around it, it does need a mention i thought
On my Fedora13(32-bit) machine the libev headers are in /usr/lib/libev which is not where the bjoern is looking for when it compiles.
This leads to failure in compilation.
In file included from bjoern/request.c:3:
bjoern/request.h:4:16: error: ev.h: No such file or directory
In file included from bjoern/request.c:3:
bjoern/request.h:38: error: expected specifier-qualifier-list before ‘ev_io’
bjoern/request.c: In function ‘Request_new’:
bjoern/request.c:30: error: ‘Request’ has no member named ‘parser’
bjoern/request.c:31: error: ‘Request’ has no member named ‘parser’
bjoern/request.c:33: error: ‘Request’ has no member named ‘headers’
bjoern/request.c:34: error: ‘Request’ has no member named ‘body’
bjoern/request.c:35: error: ‘Request’ has no member named ‘response’
bjoern/request.c:36: error: ‘Request’ has no member named ‘status’
bjoern/request.c: In function ‘Request_parse’:
bjoern/request.c:45: error: ‘Request’ has no member named ‘parser’
bjoern/request.c: In function ‘Request_free’:
bjoern/request.c:58: error: ‘Request’ has no member named ‘response’
bjoern/request.c:58: error: ‘Request’ has no member named ‘response’
bjoern/request.c:58: error: ‘Request’ has no member named ‘response’
bjoern/request.c:58: error: ‘Request’ has no member named ‘response’
bjoern/request.c:66: error: ‘Request’ has no member named ‘body’
bjoern/request.c:66: error: ‘Request’ has no member named ‘body’
bjoern/request.c:66: error: ‘Request’ has no member named ‘body’
bjoern/request.c:66: error: ‘Request’ has no member named ‘body’
bjoern/request.c:67: error: ‘Request’ has no member named ‘headers’
bjoern/request.c:69: error: ‘Request’ has no member named ‘status’
bjoern/request.c:71: error: ‘Request’ has no member named ‘headers’
bjoern/request.c:71: error: ‘Request’ has no member named ‘headers’
bjoern/request.c:71: error: ‘Request’ has no member named ‘headers’
bjoern/request.c:71: error: ‘Request’ has no member named ‘headers’
bjoern/request.c:72: error: ‘Request’ has no member named ‘status’
bjoern/request.c:72: error: ‘Request’ has no member named ‘status’
bjoern/request.c:72: error: ‘Request’ has no member named ‘status’
bjoern/request.c:72: error: ‘Request’ has no member named ‘status’
bjoern/request.c: In function ‘on_message_begin’:
bjoern/request.c:155: error: ‘Request’ has no member named ‘headers’
bjoern/request.c: In function ‘on_path’:
bjoern/request.c:166: error: ‘Request’ has no member named ‘headers’
bjoern/request.c: In function ‘on_query_string’:
bjoern/request.c:176: error: ‘Request’ has no member named ‘headers’
bjoern/request.c: In function ‘on_url’:
bjoern/request.c:186: error: ‘Request’ has no member named ‘headers’
bjoern/request.c: In function ‘on_fragment’:
bjoern/request.c:196: error: ‘Request’ has no member named ‘headers’
bjoern/request.c: In function ‘on_header_field’:
bjoern/request.c:208: error: ‘Request’ has no member named ‘headers’
bjoern/request.c: In function ‘on_headers_complete’:
bjoern/request.c:243: error: ‘Request’ has no member named ‘headers’
bjoern/request.c: In function ‘on_body’:
bjoern/request.c:254: error: ‘Request’ has no member named ‘body’
bjoern/request.c:259: error: ‘Request’ has no member named ‘body’
bjoern/request.c:262: error: ‘Request’ has no member named ‘body’
bjoern/request.c: In function ‘on_message_complete’:
bjoern/request.c:275: error: ‘Request’ has no member named ‘headers’
bjoern/request.c:278: error: ‘Request’ has no member named ‘headers’
bjoern/request.c:281: error: ‘Request’ has no member named ‘headers’
bjoern/request.c:287: error: ‘Request’ has no member named ‘body’
bjoern/request.c:287: error: ‘Request’ has no member named ‘body’
bjoern/request.c:287: error: ‘Request’ has no member named ‘headers’
bjoern/request.c:295: error: ‘Request’ has no member named ‘headers’
bjoern/request.c:300: error: ‘Request’ has no member named ‘headers’
error: command 'gcc' failed with exit status 1
It works fine if i copy the headers in the bjoern directory and modify server.c and request.h accordingly.
Is it possible to create a bjoern backend for chaussette ?
I doesn't look that complicated but I don't know where to start.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.