7
7
8
8
from . import base_events
9
9
from . import constants
10
- from . import futures
11
10
from . import protocols
12
11
from . import transports
13
12
from .log import logger
@@ -609,7 +608,7 @@ def _start_handshake(self):
609
608
def _check_handshake_timeout (self ):
610
609
if self ._in_handshake is True :
611
610
msg = (
612
- f"SSL handshake for { self } is taking longer than "
611
+ f"SSL handshake is taking longer than "
613
612
f"{ self ._ssl_handshake_timeout } seconds: "
614
613
f"aborting the connection"
615
614
)
@@ -627,12 +626,9 @@ def _on_handshake_complete(self, handshake_exc):
627
626
peercert = sslobj .getpeercert ()
628
627
except Exception as exc :
629
628
if isinstance (exc , ssl .CertificateError ):
630
- msg = (
631
- f'{ self } : SSL handshake failed on verifying '
632
- f'the certificate'
633
- )
629
+ msg = 'SSL handshake failed on verifying the certificate'
634
630
else :
635
- msg = f' { self } : SSL handshake failed'
631
+ msg = ' SSL handshake failed'
636
632
self ._fatal_error (exc , msg )
637
633
return
638
634
@@ -702,13 +698,19 @@ def _process_write_backlog(self):
702
698
raise
703
699
704
700
def _fatal_error (self , exc , message = 'Fatal error on transport' ):
701
+ if isinstance (exc , base_events ._FATAL_ERROR_IGNORE ):
702
+ if self ._loop .get_debug ():
703
+ logger .debug ("%r: %s" , self , message , exc_info = True )
704
+ else :
705
+ self ._loop .call_exception_handler ({
706
+ 'message' : message ,
707
+ 'exception' : exc ,
708
+ 'transport' : self ._transport ,
709
+ 'protocol' : self ,
710
+ })
705
711
if self ._transport :
706
712
self ._transport ._force_close (exc )
707
713
708
- if (self ._loop .get_debug () and
709
- isinstance (exc , base_events ._FATAL_ERROR_IGNORE )):
710
- logger .debug ("%r: %s" , self , message , exc_info = True )
711
-
712
714
def _finalize (self ):
713
715
self ._sslpipe = None
714
716
0 commit comments