[issue43622] TLS 1.3, client polling returns event without data

gchauvel report at bugs.python.org
Tue Mar 30 04:40:23 EDT 2021


gchauvel <guillaume.chauvel at gmail.com> added the comment:

Based on your first comment, poll returning an event and recv not able to read data is a behavior to expect with TLSv1.2/TLSv1.3 (or ...)
So in order to use SSLContext in a polling loop with multiple file descriptors, a non-blocking mode (to avoid an fd event and not being able to read data) is mandatory. Do you agree with this statement ?

Furthermore, I looked at [1], the other tests in test_ssl.py and also set a few traces in _ssl.c

- without non blocking mode: even with a fd event, the test blocks on SSL_read
- with non blocking mode: SSL_read returns a negative value, PySSL_SetError throws PySSLWantWriteErrorObject, but:

    nothing is printed on the console, a thread is blocked at PyThread_acquire_lock_timed, so the test hangs forever.

- with non blocking mode + try/except ssl.SSLWantReadError [2], the test is ok

[1] https://docs.python.org/3/library/ssl.html#ssl-nonblocking
[2] https://github.com/g-chauvel/cpython/commit/dc57cbea3558ff7b3c040326709d9b759214584a

----------

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


More information about the Python-bugs-list mailing list