'run one iteration of a simple worker engine'

def run_worker(self):

    tries = 0
    while True:
        atask = self.conn.poll_for_activity_task(self._domain, self._task_list, identity='test    worker')
        if (atask.get('activityId') is not None):
            break
        time.sleep(2)
        tries += 1
        if (tries > 10):
            assert False, 'no    activity    task    occurred'
    reason = None
    try:
        result = json.dumps(sum(json.loads(atask['input'])))
    except:
        reason = 'an    exception    was    raised'
        details = traceback.format_exc()
    if (reason is None):
        r = self.conn.respond_activity_task_completed(atask['taskToken'], result)
    else:
        r = self.conn.respond_activity_task_failed(atask['taskToken'], reason=reason, details=details)
    assert (r is None)
