Serving static files with add_static() breaks event loop on windows #1401
Closed
Description
Long story short
Serving big static file makes impossible to process new requests at this time. Event loop does not pass execution to other coroutines.
If client stops to receive file in the middle of transfer then server becomes broken - it cannot receive/process new requests.
Expected behaviour
Other requests can be processed while file is served.
Actual behaviour
Server hangs for some time or becomes broken forever.
Steps to reproduce
Server:
from aiohttp import web
def index(request):
return web.Response(text='hello world')
app = web.Application()
app.router.add_get('/', index)
app.router.add_static('/static/', path=str('./test/'))
web.run_app(app)
Client:
import asyncio
from aiohttp import ClientSession
async def download(file):
async with ClientSession() as session:
async with session.get(file) as resp:
while True:
data = await resp.content.read(1000)
if not data:
break
await asyncio.sleep(1)
loop = asyncio.get_event_loop()
loop.run_until_complete(download('http://127.0.0.1:8080/static/1.mkv'))
loop.close()
- Copy your favourite movie to test/1.mkv
- Run server
- Try to fetch page http://127.0.0.1:8080/
- Run client
- Try to fetch page http://127.0.0.1:8080/ one more time
Your environment
aiohttp (1.1.3)
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
Win10