Strange behavior of StreamServer._handle_and_close_when_done when using TLS protection

50 views
Skip to first unread message

Kevin Tewouda

unread,
Sep 22, 2019, 1:40:58 PM9/22/19
to gevent: coroutine-based Python network library
Hello everyone,
I experimented a simple HTTP2 server with gevent and it works pretty well. The source code is available here.
But when I want to improve by processing multiple requests in parallel using spawn at line 173, I notice that the server hangs indefinitely.
When I remove the ssl_context flag when running the server, I have no issue. I started the monitoring thread to see where it hangs and I
notice that it is the function _handle_and_close_when_done which seems to hang but I have trouble to understand why. Here is the output
I got below

2019-09-22T17:19:43Z : Greenlet <Greenlet at 0x435f270: _handle_and_close_when_done(<bound method StreamServer.wrap_socket_and_handle , <bound method StreamServer.do_close of <StreamServ, (<gevent._socket3.socket [closed]  object, fd=-1, )> appears to be blocked
   
Reported by <gevent.__tracer.GreenletTracer object at 0x04833060>
Blocked Stack (for thread id 0x4388):
 
File "C:\Users\rolla\.virtualenvs\gevent_socket-df9ioMif\lib\site-packages\gevent\baseserver.py", line 26, in _handle_and_close_when_done
   
return handle(*args_tuple)
 
File "C:\Users\rolla\.virtualenvs\gevent_socket-df9ioMif\lib\site-packages\gevent\server.py", line 202, in wrap_socket_and_handle
   
return self.handle(ssl_socket, address)
 
File "D:/projets/python/gevent_socket/h2_server/__init__.py", line 70, in __init__
   
self._run()
 
File "D:/projets/python/gevent_socket/h2_server/__init__.py", line 176, in _run
    data
= self._sock.recv(65535)
<Greenlet at 0x435f270: _handle_and_close_when_done(<bound method StreamServer.wrap_socket_and_handle , <bound method StreamServer.do_close of <StreamServ, (<gevent._socket3.socket [closed]  object, fd=-1, )>
 
File "C:\Users\rolla\AppData\Local\Programs\Python\Python37-32\Lib\ssl.py", line 1034, in recv
   
return self.read(buflen)
5.0
 
File "C:\Users\rolla\AppData\Local\Programs\Python\Python37-32\Lib\ssl.py", line 910, in read
================================================================================
   
return self._sslobj.read(len)

Info:
********************************************************************************
* Threads
********************************************************************************
Thread 0x3c64 (None) (CURRENT)

 
File "C:\Users\rolla\.virtualenvs\gevent_socket-df9ioMif\lib\site-packages\gevent\_monitor.py", line 203, in __call__
    f
(hub)
 
File "C:\Users\rolla\.virtualenvs\gevent_socket-df9ioMif\lib\site-packages\gevent\_monitor.py", line 236, in monitor_blocking
    dict
(greenlet_stacks=False, current_thread_ident=self.monitor_thread_ident))
 
File "C:\Users\rolla\.virtualenvs\gevent_socket-df9ioMif\lib\site-packages\gevent\util.py", line 152, in format_run_info
    _format_thread_info
(lines, thread_stacks, limit, current_thread_ident)
 
File "C:\Users\rolla\.virtualenvs\gevent_socket-df9ioMif\lib\site-packages\gevent\util.py", line 177, in _format_thread_info
    lines
.append(''.join(traceback.format_stack(frame, limit)))

My environment:
- Windows 10
- Gevent 1.5.a1
- Python 3.7

If somebody can help me, that will be nice :)
Reply all
Reply to author
Forward
0 new messages