#NEWLINE# def handle( self , * args , **options ) : #NEWLINE# #INDENT# user_count = ( options [ 'count' ] + 1 ) #NEWLINE# year = options [ 'year' ] #NEWLINE# users = range ( 1 , user_count ) #NEWLINE# versions = list ( Version . objects . select_related ( 'app' , 'platform' ) . filter_by_enabled ( ) ) #NEWLINE# versions += list ( SparkleVersion . objects . select_related ( 'app' ) . filter_by_enabled ( ) ) #NEWLINE# channels = list ( Channel . objects . all ( ) ) #NEWLINE# job_size = ( int ( ( user_count / ( cpu_count ( ) or ( 1 * 2 ) ) ) ) or 1 ) #NEWLINE# job_data = [ user_count [ i : ( i + job_size ) ] for i in range ( 0 , len ( users ) , job_size ) ] #NEWLINE# pool = Pool ( ) #NEWLINE# pool . imap_unordered ( partial ( run_worker , versions = versions , channels = channels , year = year ) , job_data ) #NEWLINE# pool . close ( ) #NEWLINE# pool . join ( )