def long_task(self): """Background task that runs a long function with progress reports.""" Tests.client_code(testOne) message = '' total = random.randint(10, 50) for i in range(total): self.update_state(state='PROGRESS', meta={ 'current': i, 'total': total, 'status': message }) time.sleep(1) return { 'current': 100, 'total': 100, 'status': 'Task completed!', 'result': 42 }