<s> """<STR_LIT>""" <EOL> from tornado . web import asynchronous <EOL> from sockjs . tornado . transports import streamingbase <EOL> class EventSourceTransport ( streamingbase . StreamingTransportBase ) : <EOL> name = '<STR_LIT>' <EOL> @ asynchronous <EOL> def get ( self , session_id ) : <EOL> self . preflight ( ) <EOL> self . handle_session_cookie ( ) <EOL> self . disable_cache ( ) <EOL> self . set_header ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) <EOL> self . write ( '<STR_LIT:\r\n>' ) <EOL> self . flush ( ) <EOL> if not self . _attach_session ( session_id ) : <EOL> self . finish ( ) <EOL> return <EOL> if self . session : <EOL> self . session . flush ( ) <EOL> def send_pack ( self , message , binary = False ) : <EOL> if binary : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> msg = '<STR_LIT>' % message <EOL> self . active = False <EOL> try : <EOL> self . notify_sent ( len ( msg ) ) <EOL> self . write ( msg ) <EOL> self . flush ( callback = self . send_complete ) <EOL> except IOError : <EOL> self . session . delayed_close ( ) <EOL> self . _detach ( ) </s>
