[issue34411] ProactorEventLoop should use implement GetAddrInfo, GetNameInfo

Yury Selivanov report at bugs.python.org
Wed Aug 15 13:44:37 EDT 2018


Yury Selivanov <yselivanov at gmail.com> added the comment:

> As far as our experiments show, the requests are blocking each other irrespective of thread pool size. Which is expected since the lock is global across threads.

It looks like you don't understand how GIL works in Python (sorry if I'm mistaken).

The GIL prevents two threads from simultaneously executing *pure Python* code.  Whenever Python code does a system call, the GIL is released for that thread, allowing other Python code in other threads to execute.  Therefore, getaddrname calls in threadpools can't block each other or the event loop thread in any way.

There's a max capacity for the threadpool though, so if you're making 100s of getaddrname calls you'll indeed see some slowdown.  Using IOCP for getaddsname can remove this bottleneck.

> Am I correct in assuming that an implementation for the ProactorEventLoop with IOCP would not require a global lock?

I think so, because we can have as many getaddrcalls as we want all monitored by IOCP for us.  But I'm not an expert in IOCP, so if you want to work on the patch I can't really help you with details.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34411>
_______________________________________


More information about the Python-bugs-list mailing list