#NEWLINE# def create_sink( ) : #NEWLINE# #INDENT# ' Return a new Sink with a numeric ID incremented in a threadsafe way ' #NEWLINE# global last_sink_id , sink_id_lock , sinks #NEWLINE# sink_id_lock . acquire ( ) #NEWLINE# try : #NEWLINE# #INDENT# this_sink_id = last_sink_id #NEWLINE# last_sink_id = ( ( last_sink_id + 1 ) % sys . maxsize ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# sink_id_lock . release ( ) #NEWLINE# #UNINDENT# sink = Sink ( this_sink_id ) #NEWLINE# sinks [ this_sink_id ] = sink #NEWLINE# return sink