if __name__ == '__main__'section at the bottom of
bjoern.py(or your module), and then use something like
argparseto create a command-line parser. Then it's available with
python -m bjoern .... Having it in
PATHdirectly like with gunicorn doesn't really anything to that.
@stuz5000 concurrenct connections != threading != shared memory. What are you trying to accomplish?
bjoern can easily support a large number of concurrent connections. It doesn't support threads or multiprocessing. However you can spawn multiple bjoern workers to listen on the same port with SO_REUSEPORT (https://lwn.net/Articles/542629/), or you can fork multiple workers (see tests/fork.py)
@stuz5000 From your web application's point of view you've got a typical I/O bound model here. bjoern does not care about I/O out of the box -- you'll have to make your application yield manually: A loop like
while not done(): yield
which will be polled by the bjoern event loop. But this doesn't scale well and wastes loads of CPU. You'll be off much better using something like gunicorn/geventlet, meinheld, or something asyncio based like uvloop.
I was hoping maybe someone can help me out, I must be doing something wrong here but I've tried everything and cant figure it out.
Im getting the following error:
Traceback (most recent call last): File "./src/bjoern.py", line 5, in <module> bjoern.run(api.app) AttributeError: module 'bjoern' has no attribute 'run'
bjoern.py file contains the following:
import bjoern import api if __name__ == '__main__': bjoern.run(api.app)