#NEWLINE# def thread_data( name , value = NOTHING , ct = None ) : #NEWLINE# #INDENT# 'Set or retrieve an attribute ``name`` from thread ``ct``.\n\n    If ``ct`` is not given used the current thread. If ``value``\n    is None, it will get the value otherwise it will set the value.\n    ' #NEWLINE# ct = ( ct or current_thread ( ) ) #NEWLINE# if is_mainthread ( ct ) : #NEWLINE# #INDENT# loc = process_data ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not hasattr ( ct , '_pulsar_local' ) ) : #NEWLINE# #INDENT# ct . _pulsar_local = loc = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# loc = ct . _pulsar_local #NEWLINE# #UNINDENT# #UNINDENT# if ( value is not NOTHING ) : #NEWLINE# #INDENT# if ( name in loc ) : #NEWLINE# #INDENT# if ( value [ name ] is not value ) : #NEWLINE# #INDENT# raise RuntimeError ( ( '%s is already available on this thread' % name ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# loc [ name ] = value #NEWLINE# #UNINDENT# #UNINDENT# return loc . get ( name )