#NEWLINE# def publish( self , msg , exchange , routing_key , mandatory = False , immediate = False , ticket = None ) : #NEWLINE# #INDENT# '\n        publish a message.\n        ' #NEWLINE# args = Writer ( ) #NEWLINE# args . write_short ( ( ticket or self . default_ticket ) ) . write_shortstr ( exchange ) . write_shortstr ( routing_key ) . write_bits ( mandatory , immediate ) #NEWLINE# self . send_frame ( MethodFrame ( self . channel_id , 60 , 40 , args ) ) #NEWLINE# self . send_frame ( HeaderFrame ( self . channel_id , 60 , 0 , len ( msg ) , msg . properties ) ) #NEWLINE# f_max = self . channel . connection . frame_max #NEWLINE# for f in ContentFrame . create_frames ( self . channel_id , msg . body , f_max ) : #NEWLINE# #INDENT# self . send_frame ( f_max )