pyGrowler / Growler

A micro web-framework using asyncio coroutines and chained middleware.
http://www.growler.rocks
Apache License 2.0
686 stars 29 forks source link

Using Uvloop in Growler #8

Closed machbio closed 8 years ago

machbio commented 8 years ago

I recently came across Growler, it looks pretty good framework to move away from Flask that I am currently using.

But I have seen some improvements on the loop with https://github.com/MagicStack/uvloop - the benchmark seems to show it is better event loop as compared to Asyncio Event loop. so can I replace the Event loop from the current example to use Uvloop - just wanted to know if I am missing anything.

Asyncio Loop

loop = asyncio.get_event_loop()
app = App('GrowlerServer', loop=loop)

Uvloop

 loop = uvloop.new_event_loop()
 app = App('GrowlerServer', loop=loop)

I understand that #4 its been brought forward - but should it not be as straightforward as given above.

akubera commented 8 years ago

The way I'm using uvloop currently is

import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

at the beginning of my main.py, before the app is created. This is how http://growler.rocks is running (which is currently as single page site and any framework/accelerator is unnecessary).

Let me know if the other syntax works.

machbio commented 8 years ago

Thank you, looks like there is no need of worrying about uvloop integration