<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def worker(namespace, name, branch='master'):
    '''The simple_ci background worker process'''
    with repository(namespace, name, branch) as (path, latest, cache):
        if cache.get(latest, None) and json.loads(cache[latest])['status'] != 'starting':
            return 'Build already started'

        data = {'status': 'in_progress', 'result': ''}
        cache[latest] = json.dumps(data)
        test_output = tox(_iter=True)
        try:
            for line in test_output:
                data['result'] += line
                cache[latest] = json.dumps(data)
            data['build_success'] = True
        except Exception:
            data['build_success'] = False
        data['status'] = 'complete'
        cache[latest] = json.dumps(data)
        return 'Build successfully completed'