uvloop icon indicating copy to clipboard operation
uvloop copied to clipboard

uvloop blocks app and not executes aiohttp server

Open semakmillev opened this issue 4 years ago • 5 comments

Hi! I have very strange bug. On server (only on the one - i cant reproduce error on others) i m tryin to start application using uvloop. Here is the code (i tried using docker, or executing script - result was the same) in console:

Python 3.8.10 (default, Jun 2 2021, 10:49:15) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information.

import uvloop asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) # here i tried uvloop.install() from aiohttp import web app = web.Application() web.run_app(app, port=17000)

And after that nothing happens! Moreover, i can't stop process using Ctrl+C or Ctrl+D - only kill from other console

*i changed ports and got same results

uvloop version: 0.15.3 OS Version: NAME="Ubuntu" VERSION="20.04.1 LTS (Focal Fossa)"

semakmillev avatar Jul 21 '21 15:07 semakmillev

Sounds like the 17000 port is used by something else on that particular server. And most likely aiohttp has some timeout/retry logic in place and waits for it to become available. I don't think this is a uvloop bug. That said, check what happens if you don't activate uvloop -- does vanilla asyncio behave differently?

1st1 avatar Jul 21 '21 15:07 1st1

Sounds like the 17000 port is used by something else on that particular server. And most likely aiohttp has some timeout/retry logic in place and waits for it to become available. I don't think this is a uvloop bug. That said, check what happens if you don't activate uvloop -- does vanilla asyncio behave differently?

  1. As i mentioned - i used different ports - like 8023, 7091, 17091, 17000, 80 and several another with same result
  2. Yes, if i run just from aiohttp import web app = web.Application() web.run_app(app, port=17000) everything works fine.

It's really strange. Seems that i have some hardware or system problem, because on other machine with same software i don't get this bug. But how to find out it - i dont know(

semakmillev avatar Jul 21 '21 16:07 semakmillev

Hello.

I have the same issue after upgrade libs:

works fine: python 3.6 aiohttp 3.6.2 uvloop 0.14.0

issue: python 3.7, 3.9 aiohttp 3.7.4.post0 uvloop 0.16.0

If I have only one pod - it was ok, but when I start 2nd pod - pod doesn't listen 8080 port

My system: sh-4.2# cat /etc/*release : CentOS Linux release 7.8.2003 (Core)

If I run without uvloop.install() - it was ok.

When I set Debug mode: PYTHONASYNCIODEBUG=1 I finally got a log:

WARNING:asyncio:create_server() failed to create socket.socket(10, 1, 6) Traceback (most recent call last): File "uvloop/loop.pyx", line 1745, in uvloop.loop.Loop.create_server File "/usr/local/lib/python3.9/socket.py", line 232, in init _socket.socket.init(self, family, type, proto, fileno) OSError: [Errno 97] Address family not supported by protocol

roman27t avatar Sep 24 '21 11:09 roman27t

@bumer-t , @semakmillev were you able to figure out the root cause or solution to this problem? I am facing similar issues.

nehanagendra02 avatar Oct 08 '21 09:10 nehanagendra02

Try set ipv4 address, because by default it will try to bind to ipv6 first

kfur avatar Oct 11 '21 15:10 kfur