Skip to content

requests calls always need a timeout definition#2727

Merged
ReimarBauer merged 9 commits intoOpen-MSS:stablefrom
ReimarBauer:timeout
Mar 25, 2025
Merged

requests calls always need a timeout definition#2727
ReimarBauer merged 9 commits intoOpen-MSS:stablefrom
ReimarBauer:timeout

Conversation

@ReimarBauer
Copy link
Member

Purpose of PR?:
... or they can indefinite wait

Also set per module a global MSCOLAB_TIMEOUT to reduce calls of config_loader

Fixes #2726

@ReimarBauer ReimarBauer requested a review from matrss March 24, 2025 08:00
else:
img_url = urljoin(self.chat_window.mscolab_server_url, self.attachment_path)
data = requests.get(img_url, timeout=tuple(config_loader(dataset="MSCOLAB_timeout"))).content
data = requests.get(img_url, timeout=MSCOLAB_TIMEOUT).content
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unrelated issue: this accesses the responses content without first checking for success.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, first step I wanted to solve only timeout configurations. There are likly more like that.

session.headers.update({'x-test': 'true'})
# ToDp fix config_loader it gets a list of two times the entry
response = session.get(urljoin(msc_url, 'status'), timeout=tuple(config_loader(dataset="MSCOLAB_timeout")[0]))
response = session.get(urljoin(msc_url, 'status'), timeout=MSCOLAB_TIMEOUT[0])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does it only take the first element here, unlike in the other places?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have no idea, I had that once changed to the common, but decided to keep the value until that question is looked up.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a bug #2730 the ToDo was a hint.

I try to write a test for that first.

from mslib.utils.config import config_loader, modify_config_file


MSCOLAB_TIMEOUT = tuple(config_loader(dataset="MSCOLAB_timeout"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this actually make a measurable difference?

Copy link
Member Author

Choose a reason for hiding this comment

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

less characters on other places and the option to try different values for a module.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The downside is that this could lead to using an outdated value when the configuration is changed while the application is running. I think this value wouldn't be updated if MSCOLAB_timeout is changed in the configuration editor, even with the application restart that it does.

Copy link
Member Author

Choose a reason for hiding this comment

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

the editor has another bug -> new issue coming.
Bildschirmfoto 2025-03-24 um 20 05 19

and there is another problem by that var or on the MBP
Bildschirmfoto 2025-03-24 um 20 17 03

That was not expected.

Copy link
Member Author

Choose a reason for hiding this comment

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

Anyway it is more important to have always a timeout there then a short cut module global. It is an easy refactoring.

Copy link
Collaborator

@matrss matrss left a comment

Choose a reason for hiding this comment

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

There are two locations in docs/samples/automation/retriever.py where there is no timeout specified yet.

@ReimarBauer
Copy link
Member Author

There are two locations in docs/samples/automation/retriever.py where there is no timeout specified yet.

That was removed because it is outdated

@ReimarBauer ReimarBauer merged commit e77fe34 into Open-MSS:stable Mar 25, 2025
6 of 8 checks passed
@ReimarBauer ReimarBauer deleted the timeout branch March 25, 2025 18:30
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.

2 participants