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

improved loop handling #158

Merged
merged 1 commit into from
Nov 24, 2017
Merged

improved loop handling #158

merged 1 commit into from
Nov 24, 2017

Conversation

samuelcolvin
Copy link
Member

fixes #156
replaces #157

This package passed loops around a lot, this was mainly required for tests to pass with python < 3.5.2 where set_event_loop didn't work properly.

This in turn was causing problems with uvloop, either meaning the wrong loop was used or a "different loop" error occurred.

The fixes here can be demonstrated by the micro example

from aiohttp import web
import asyncio
import uvloop

async def handle(request):
    return web.Response(text=f'loop: {request.app.loop}')

asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
app = web.Application()
app.router.add_get('/', handle)

Run with

adev runserver demo.py

Should now return loop: <uvloop.Loop running=True closed=False debug=False> while before it was using the standard python loop.

@vladiibine would be great if you could try this and confirm it works for you.

@codecov
Copy link

codecov bot commented Nov 24, 2017

Codecov Report

Merging #158 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #158      +/-   ##
==========================================
+ Coverage    94.9%   94.91%   +<.01%     
==========================================
  Files          13       13              
  Lines         766      767       +1     
  Branches       93       93              
==========================================
+ Hits          727      728       +1     
  Misses         25       25              
  Partials       14       14
Impacted Files Coverage Δ
aiohttp_devtools/runserver/serve.py 94.29% <100%> (ø) ⬆️
aiohttp_devtools/version.py 100% <100%> (ø) ⬆️
aiohttp_devtools/runserver/config.py 88.37% <100%> (+0.09%) ⬆️
aiohttp_devtools/runserver/main.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96ee738...aa5cd39. Read the comment docs.

Copy link

@vladiibine vladiibine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the changes, and at least the live reload works. Couldn't dwelve into the code more than this, so I don't get the full extent of the changes, but seems like it should be fine. I'll keep you updated if I find other issues :) Thanks a lot for yout time!

@samuelcolvin samuelcolvin merged commit c03a16d into master Nov 24, 2017
@samuelcolvin samuelcolvin deleted the better-loop-handling branch November 24, 2017 17:07
@samuelcolvin
Copy link
Member Author

no problem, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't set a non-default event loop when running adev runserver
2 participants