Skip to content
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

Use aiofiles in static file serving #1404

Closed
asvetlov opened this issue Nov 15, 2016 · 6 comments
Closed

Use aiofiles in static file serving #1404

asvetlov opened this issue Nov 15, 2016 · 6 comments
Labels

Comments

@asvetlov
Copy link
Member

See also #1401

@AraHaan
Copy link
Contributor

AraHaan commented Nov 22, 2016

Wow such bug. I am one for this needing fixed on the event loop. I guesas it is possible (to bypass it( to have a for loop to check if the loop is closed and if so use asyncio.new_event_loop() also note that sometimes get_event_loop() can actually return a closed loop and so one can create their own copy of get_event_loop() that can check if the loop is closed as well. I would recommend that so that way their get_event_loop actually handles recreating the actual loop.

So yeah that is another possibility to hack bypass such bug.

like one can:

def get_event_loop()
    """"
    Gets an asyncio event loop. And checks to see if it is not closed.
    if the loop is closed this handles crating a new event loop.
    :returns: asyncio Event loop
    """
    loop = asyncio.get_event_loop()
    if loop.is_closed():
        loop = asyncio.new_event_loop()
    return loop

That code above is how I personally bypass closed event loops and a RuntimeError when the event loop is closed.

@asvetlov
Copy link
Member Author

@AraHaan
I don't understand how your comment is related ti the issue.
But silent loop reopening with implicit replacement is definitely an ugly idea.
Please never do this.

@AraHaan
Copy link
Contributor

AraHaan commented Nov 23, 2016

Well unless I use a lib (discord.py) which closes the loop when I dont want it to. Which is the reason I have to hack reopen it as most of the time it goes offline when I cant restart it so it just saves it from not being able to recover from it.

@asvetlov
Copy link
Member Author

asvetlov commented Dec 1, 2016

After a glance on discord.py I see that the library closes loop in Client.run() only.
Which is fine if Client.run() is called from main function.
But if you need to operate with discord cilen from coroutine you always could use Client.start()/Client.logout() API.

If a library closes loop -- drop the library and never use it. Or fix the library first.

@asvetlov
Copy link
Member Author

asvetlov commented Oct 3, 2018

Superseded by #3313

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants