-
-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added portable Uvicorn class #401
Conversation
Hi, I quickly took a look at the code, and it looks like you're forcing the use of I'm wondering, though — doesn't Faust support using whichever event loop is currently configured? I believe it should simply call |
I'm not forcing the use of And yes, I believe import asyncio
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
from faust import App
import uvicorn
faust_app = App(..., loop=asyncio.get_event_loop())
...
if __name__ == '__main__':
uvicorn.run(...) leads to |
Oh, yes, my bad, I didn’t realize uvloop is just a different loop that still allows using asyncio everywhere else. |
Closing this in favor of #455 which I think allows you the same functionality without us having to introduce much more API. Does that work okay for you? |
This actually doesn't work because there's no way to extract the event loop prior to
class Server:
def __init__(self, config):
self.config = config
self.server_state = ServerState()
self.started = False
self.should_exit = False
self.force_exit = False
self.last_notified = 0
# begin stuff
self.loop = None
self.event_loop_setup = False
def setup_event_loop(self):
self.config.setup_event_loop()
self.event_loop_setup = True
def get_event_loop(self):
if not self.event_loop_setup:
self.setup_event_loop()
if not self.loop:
self.loop = asyncio.get_event_loop()
return self.loop
def run(self, sockets=None, shutdown_servers=True):
loop = self.get_event_loop()
loop.run_until_complete(self.serve(sockets=sockets))
# end stuff I think the former may make more sense but is inconsistent with the current API. Please let me know what you think. Thanks! |
ReOpen it please |
why ? |
Is it' working ? I try to use uvicorn (fastapi) and faust maybe. I need an example. Cause it's not working for me. |
something like this should, feel free to ask precise questions or join the chat to get help, it's not working is not helpful
|
Yeah i join the chat to get more help :) |
My use is specifically for loop extraction to other apps, but other functionality can be added.
Includes an example in the docs using
FastAPI
andFaust
.