<s> import six <EOL> import platform <EOL> import multiprocessing <EOL> from multiprocessing . queues import Queue as BaseQueue <EOL> class SharedCounter ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , n = <NUM_LIT:0> ) : <EOL> self . count = multiprocessing . Value ( '<STR_LIT:i>' , n ) <EOL> def increment ( self , n = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> with self . count . get_lock ( ) : <EOL> self . count . value += n <EOL> @ property <EOL> def value ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . count . value <EOL> class MultiProcessingQueue ( BaseQueue ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( MultiProcessingQueue , self ) . __init__ ( * args , ** kwargs ) <EOL> self . size = SharedCounter ( <NUM_LIT:0> ) <EOL> def put ( self , * args , ** kwargs ) : <EOL> self . size . increment ( <NUM_LIT:1> ) <EOL> super ( MultiProcessingQueue , self ) . put ( * args , ** kwargs ) <EOL> def get ( self , * args , ** kwargs ) : <EOL> v = super ( MultiProcessingQueue , self ) . get ( * args , ** kwargs ) <EOL> self . size . increment ( - <NUM_LIT:1> ) <EOL> return v <EOL> def qsize ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . size . value <EOL> if platform . system ( ) == '<STR_LIT>' : <EOL> if hasattr ( multiprocessing , '<STR_LIT>' ) : <EOL> def Queue ( maxsize = <NUM_LIT:0> ) : <EOL> return MultiProcessingQueue ( maxsize , ctx = multiprocessing . get_context ( ) ) <EOL> else : <EOL> def Queue ( maxsize = <NUM_LIT:0> ) : <EOL> return MultiProcessingQueue ( maxsize ) <EOL> else : <EOL> from multiprocessing import Queue </s>
