Skip to content

Conversation

@gwbischof
Copy link
Contributor

@gwbischof gwbischof commented Jul 8, 2025

The Redis connection by default waits indefinitely for operations.
I added a test to check this behavior, and then added socket_timeout kwarg for the Redis client on the server to set the timeout.
The Redis client will now raise a TimeoutError if an operation takes too long.
Tiled provides a unhandled_exception_handler which should report a 500 error to the client and write the exception and stack trace to the logs https://github.com/bluesky/tiled/blob/de3583c96ccda2b732db0a84cd410367f16b94f0/tiled/server/app.py#L333

@gwbischof gwbischof marked this pull request as ready for review July 8, 2025 19:25
@gwbischof gwbischof requested a review from danielballan July 8, 2025 19:31
from server import Settings

# Create Redis client with timeout configuration
settings = Settings(redis_url="redis://localhost:6379/0", ttl=60 * 60)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of the LLM testing our dependency instead of testing our own library. All we're doing here is testing the behavior of redis. We put a URL in the Settings object here and then immediately pull it out. Nothing else here touches our code. I don't think we need to burden our prototype or tiled itself with these tests.

It's useful to confirm that this works—once—but I would say it's the redis library's job to unit test it.

Copy link
Contributor Author

@gwbischof gwbischof Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I was aware of that. I wanted to see the behavior of the Redis client. I also wanted to document my reasoning for the socket_timeout and show how it resolves the problem. I was hoping to avoid the situation where a reviewer says, "are you sure we need that socket_timeout", and then I have to write some code to show why we need socket_timeout. I definitely don't think the test is something we would merge into tiled. And if you don't think it should be part of the prototype I can remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants