Skip to content

Instantly share code, notes, and snippets.

@mocmocamoc
mocmocamoc / gist:8544c288a486e95514fc982a7a0e8620
Created December 12, 2017 17:58
asyncio SSL handshake timeout patch
import asyncio
def checkHandshakeDone(self):
if self._in_handshake == True:
self._abort()
asyncio.sslproto.SSLProtocol.checkHandshakeDone = checkHandshakeDone
_start_handshake_orig = asyncio.sslproto.SSLProtocol._start_handshake
def _start_handshake(self):
_start_handshake_orig(self)
self._loop.call_later(10, self.checkHandshakeDone)
asyncio.sslproto.SSLProtocol._start_handshake = _start_handshake