@cronjobs.register
def dump_user_installs_cron():
 chunk_size = 100
 user_ids = set(Installed.objects.filter(user__enable_recommendations=True).values_list('user', flat=True))
 path_to_cleanup = os.path.join(settings.DUMPED_USERS_PATH, 'users')
 task_log.info('Cleaning up path {0}'.format(path_to_cleanup))
 try:
  for (dirpath, dirnames, filenames) in walk_storage(path_to_cleanup, storage=private_storage):
   for filename in filenames:
    private_storage.delete(os.path.join(dirpath, filename))
 except OSError:
  pass
 grouping = []
 for chunk in chunked(user_ids, chunk_size):
  grouping.append(dump_user_installs.subtask(args=[chunk]))
 post = zip_users.subtask(immutable=True)
 ts = chord(grouping, post)
 ts.apply_async()

@ cronjobs . register def dump_user_installs_cron ( ) : chunk_size = 100 user_ids = set ( Installed . objects . filter ( user__enable_recommendations = True ) . values_list ( 'user' , flat = True ) ) path_to_cleanup = os . path . join ( settings . DUMPED_USERS_PATH , 'users' ) task_log . info ( 'Cleaning up path {0}' . format ( path_to_cleanup ) ) try : for ( dirpath , dirnames , filenames ) in walk_storage ( path_to_cleanup , storage = private_storage ) : for filename in filenames : private_storage . delete ( os . path . join ( dirpath , filename ) ) except OSError : pass grouping = [ ] for chunk in chunked ( user_ids , chunk_size ) : grouping . append ( dump_user_installs . subtask ( args = [ chunk ] ) ) post = zip_users . subtask ( immutable = True ) ts = chord ( grouping , post ) ts . apply_async ( )
sets up tasks to do user install dumps .