-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Separated start corountine #5386
Comments
I'm not sure why you can't commit or make a PR (isn't the error you mention from linting? You should be able to commit and create a PR without passing the checks). I'm not sure exactly what your use case is, but I think there are 2 types:
Does that solve the problem, or is there something else needed? |
It doesn't allow me to commit, the pre-commit hooks fail. When I run
My use-case is that I want to simply start the app locally but not stop execution there. I want to write code under the start that does a few other things (mostly start other things). And then handle "keeping it alive" (the while loop with a sleep) myself.
I guess I may want to try to use |
But, you must have setup pre-commit hooks, Git doesn't set them up by default (as it would be dangerous). i.e.
Should successfully commit without running any hooks. I believe hooks are under .git/hooks/, so just delete it?
That's still not very clear to me. Here's an example of things I do in my app which may or may not be similar. To achieve these, I put it all in a module which is only used when the application is run locally, all the code is then still run within the application on startup. The requirements check is just run as a blocking function, the JS bundle is run as a new Task in the background, and the subproject process is created in a cleanup_ctx, so it starts and stops with the application. Maybe this might be a better approach for whatever you are trying to achieve?
My first thought when looking at how that function works, is that it's seems complicated and not designed for public use. I'm not the one that'll make the call on whether the change gets merged or not, but my suspicion is that it would not be approved as is (although it's also difficult to tell without a diff). |
Hello! This sort of functionality is something that I'd really love to see worked into AIOHTTP in some way. Currently, to achieve the same end result I end up spinning up two separate threads and a unique event loop for each thread, one thread which for AIOHTTP and one for literally everything else as I cannot run everything on the same event loop due to the nature of run_app. I'd love to see an interface that would allow something along the lines of the following... async def main(...):
return await asyncio.gather(
webserver.run_app(...),
my_stuff(...),
) |
As explained above, running other code does work. Nobody has come up with a valid use case yet which is not supported. Either, you are running a web app (the most common scenario), in which case aiohttp should control the loop and you should hook into the app's runtime. Or, you are writing a tool that happens to run a web app (e.g. aiohttp-devtools), in which case you should manage the loop and the lifetime of the app yourself by using the app runners. Documentation for both: |
🐣 Is your feature request related to a problem? Please describe.
I want to start an
aiohttp.web.Application
non-blockingly so that I can continue executing some lines.💡 Describe the solution you'd like
I looked into it and the perfect solution would be to rename the internal
_run_app
corountine tostart_app
and then move the infinite while loop that sleeps into therun_app
function.❓ Describe alternatives you've considered
Well for my use-case I've considered copying the body of the both functions and removing the logic that makes the function blocking.
📋 Additional context
I've tried to fix it, but I get this:
(I am using Windows WSL)
I already fixed the issue. But can't commit anything (I do pass all other tests). Here is the changed/important parts of the file:
As to not make this issue too big I've pasted the entire file (if needed) on Mystbin: https://mystb.in/HalloweenPreferenceReunion.sql
I would open a pull request if I could, what can be done about this?
The text was updated successfully, but these errors were encountered: