Channels
  • Topi Hernández Mares

    Topi Hernández Mares

    1 week ago
    Hello again! I'm having a weird behavior with the Python SDK, let me try to explain it here. I'm getting the following error, but only in a specific scenario:
    RuntimeError("Cannot send a request, as the client has been closed.")
    This only happens when I make two or more requests to Cerbos with the SDK
    I have the following code:
    for id in profile_skills_ids:
        profile_skill = self.update(id=id, level=level)
    And inside
    update
    I have the
    client.is_allowed...
    for checking the auth with Cerbos
  • Charith (Cerbos)

    Charith (Cerbos)

    1 week ago
    That's strange. The internal client should only be closed when the context manager exits (or when
    close()
    is called)
    Let me try this out
    Oh wait..this is not just a simple loop. Can you please show how the Cerbos client is used inside the
    update
    method?
    Ah! The issue is that you're using the global Cerbos client within a context manager (
    with self._cerbos_client
    ). So, after the first call to
    update
    the client gets closed and no longer usable
    Remove the
    with
    and it should work
  • Topi Hernández Mares

    Topi Hernández Mares

    1 week ago
    Oh! Let me try
    Thanks, now it works!
  • Charith (Cerbos)

    Charith (Cerbos)

    1 week ago
    Yay!