-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add global http timeout to the session #61
Conversation
WalkthroughThe recent update in Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant User
participant Session
participant Server
User->>Session: Call request method
Session->>Server: Send HTTP request with default timeout
Server-->>Session: Respond to request
Session-->>User: Return response
User->>Session: Check is_logged_in property
Session-->>User: Return login status
Poem
Tip Early Access Features
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
PR Review 🔍
|
PR Code Suggestions ✨
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tyora/session.py (2 hunks)
Additional comments not posted (2)
tyora/session.py (2)
37-39
: The implementation of the default timeout in therequest
method is clean and effective. Good use ofkwargs.setdefault
to ensure user-provided values are respected.
40-40
: Please clarify what modifications were made to theis_logged_in
property as mentioned in the summary. It appears unchanged in the provided code.
@@ -10,6 +10,7 @@ | |||
|
|||
from .utils import find_link, parse_form | |||
|
|||
HTTP_TIMEOUT = int(os.getenv("HTTP_TIMEOUT", 10)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling for the conversion of HTTP_TIMEOUT
from environment variable to integer to prevent runtime errors if the environment variable is not a valid integer.
- HTTP_TIMEOUT = int(os.getenv("HTTP_TIMEOUT", 10))
+ try:
+ HTTP_TIMEOUT = int(os.getenv("HTTP_TIMEOUT", 10))
+ except ValueError:
+ logger.error("Invalid HTTP_TIMEOUT value. Using default of 10 seconds.")
+ HTTP_TIMEOUT = 10
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
HTTP_TIMEOUT = int(os.getenv("HTTP_TIMEOUT", 10)) | |
try: | |
HTTP_TIMEOUT = int(os.getenv("HTTP_TIMEOUT", 10)) | |
except ValueError: | |
logger.error("Invalid HTTP_TIMEOUT value. Using default of 10 seconds.") | |
HTTP_TIMEOUT = 10 |
User description
requests doesn't use a default timeout, this will make sure all requests have a maximum timeout configured.
PR Type
enhancement
Description
HTTP_TIMEOUT
) set to 10 seconds intyora/session.py
.request
method in theMoocfiCsesSession
class to use the default timeout, ensuring all HTTP requests have a maximum timeout configured.Changes walkthrough 📝
session.py
Add global HTTP timeout to session requests
tyora/session.py
HTTP_TIMEOUT
) set to 10 seconds.request
method to include the default timeout.Summary by CodeRabbit
New Features
Improvements
is_logged_in
property for better user experience.