@staticmethod
def worker(remote, parent_remote, env_fn_wrapper):
    """ A worker process. """
    parent_remote.close()
    env = env_fn_wrapper.env_fn
    while True:
        command, data = remote.recv()
        if command == 'step':
            ob, reward, done, info = env.step(data)
            if done:
                ob = env.reset()
            remote.send((ob, reward, done, info))
        elif command == 'reset':
            ob = env.reset()
            remote.send(ob)
        elif command == 'reset_task':
            ob = env.reset_task()
            remote.send(ob)
        elif command == 'close':
            remote.close()
            break
        elif command == 'get_spaces':
            remote.send((env.observation_space, env.action_space))
        else:
            raise NotImplementedError
