Coder Social home page Coder Social logo

bjoern's People

Contributors

bersace avatar cloudaice avatar defnull avatar eklitzke avatar fredreichbier avatar gitter-badger avatar goldsteine avatar huayanghao avatar ijs-octo avatar jameslittle avatar jonashaag avatar k3d3 avatar kkris avatar marsam avatar mineo avatar ndlarsen avatar nhoad avatar olivierduchateau avatar parazyd avatar patricklucas avatar paulocheque avatar rbanffy avatar shumen avatar szabolcsbalogh avatar temoto avatar thefab avatar tjb1982 avatar trollfot avatar varbin avatar x-yuri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bjoern's Issues

segfault introduced in e268

When running tests/hello.py two requests succeed and the third segfaults. Reverting to 772d resolves the issue on my system.

Cannot checkout http-parser submodule [refers to non-existing tree]

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'

Installation still failing on Mac OS X 10.6.5

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

SIGINT (or some other) handler must wait for last request to complete

ev_signal_on_sigint(struct ev_loop* mainloop, ev_signal* watcher, const int events)

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.

flask does not run in bjoern server

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)

Examples on graceful reloading server process

The example on how to fork server process on multiple core servers. However, is there any way to gracefully stop and restart server processes?

  • block socket to not accept more connections
  • close socket when all the current requests are handled and responses sent
  • close server processes
  • reread configuration files
  • starts new server processes

It would be great if test cases for this feature are added

Thanks

Benchmark versus uwsgi

How is bjoern performing comparing to uwsgi?
Both of them are written in C.
What are the differences?

Bjoern Installation Fails on Mac OS X 10.6 w/ Homebrew, Xcode 4

Interestingly enough, a fresh install still produces errors. The process:

  1. Install Mac OS X 10.6.
  2. Install Xcode 4 Build 4A225.
  3. Install latest Python 2.7 from .pkg installer.
  4. Install homebrew and run: brew install libev
  5. Install virtualenv for 2.7, create a new environment, and enter it.
  6. Run: pip install bjoern

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.

infinity waiting

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!

Keepalive not working?

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.

run as service in ubuntu

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

How bjoern deal with I/O ops in request handlers?

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

Installation issues.

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.

python3

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?

thread.local support

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?

Could it work under Python 2.5?

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?

Installation fails on Mac OS X 10.6.

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?

Problems in start_response with bottle.py

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

libev error

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

Incompatible data type on ARM

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!

unquote_url_inplace shouldn't unquote in place (or exist?)

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.

*BSD support?

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!!

Error while installing on ubuntu 14.04

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

Request IP/host

Would it be difficult to include a REQUEST_IP key in the request dictionary? Is there already an obvious method of obtaining this information?

bjoern and gevent

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?

can't install

$ 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’

http-parser/http_parser.c is missing

thatoneguy@thebadpipsissewah:/bjoern$ python ./setup.py build
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:
/bjoern$ ls http-parser/
thatoneguy@thebadpipsissewah:~/bjoern$

commit c79d7b1
Author: Jonas Haag [email protected]
Date: Fri Jun 7 01:14:14 2013 +0200

Version 1.3.2

could't stop all process, when start server like tests/fork.py

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.

errors with pip install bjoern

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

Start multiple processes

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...

Document (implement?) logging

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.

Problem with query string

"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?

Python 2.7.6 ImportError

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!

Building fails on Arch Linux

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?

Any way to prevent the use of sendfile?

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.