#NEWLINE# def shutdown_if_ready( self ) : #NEWLINE# #INDENT# "Shutdown if it's time to shutdown" #NEWLINE# if ( ( fd . _allowed_gets > 0 ) and ( self . _allowed_gets <= self . _state [ 'num_gets' ] ) ) : #NEWLINE# #INDENT# num_post_backs = self . _state [ 'num_posts' ] #NEWLINE# if ( self . _allow_post_backs and ( num_post_backs < self . _allowed_gets ) ) : #NEWLINE# #INDENT# log . info ( 'Waiting for {} more post backs from client' . format ( ( self . _allowed_gets - num_post_backs ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# log . info ( 'Served resource {} times. Done. Waiting for network buffers to clear' . format ( self . _state [ 'num_gets' ] ) ) #NEWLINE# for ( fd , sock ) in httpd . _sockets . items ( ) : #NEWLINE# #INDENT# sock . setblocking ( True ) #NEWLINE# sock . settimeout ( 0.1 ) #NEWLINE# try : #NEWLINE# #INDENT# sock . send ( b'' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# tornado . ioloop . IOLoop . current ( ) . stop ( )