Skip to content

improve multi_timeseries call#150

Merged
Enovotny merged 5 commits into
mainfrom
timeout/threading_improvement
Jun 9, 2025
Merged

improve multi_timeseries call#150
Enovotny merged 5 commits into
mainfrom
timeout/threading_improvement

Conversation

@Enovotny

@Enovotny Enovotny commented Jun 6, 2025

Copy link
Copy Markdown
Collaborator
  • update to improve multi_timeseries call to use concurrent.futures instead of threading.
  • Added retries for all API calls if connection fails. Retries set to 6.

@Enovotny Enovotny requested a review from krowvin June 6, 2025 17:50
@Enovotny Enovotny linked an issue Jun 6, 2025 that may be closed by this pull request
begin: Optional[datetime] = None,
end: Optional[datetime] = None,
melted: Optional[bool] = False,
max_workers: Optional[int] = 30,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You have 30 here but below in the doc you suggest it would be 32 from 3.8 on, maybe change this to 32 to match that?

ts_ids: linst
a list of timeseries to get. If the timeseries is a verioned timeseries then serpeate the ts_id from the
ts_ids: list
a list of timeseries to get. If the timeseries is a versioned timeseries then separate the ts_id from the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would consider breaking your commits by task, or 1 commit for renaming (spell checking) and another for the multi TS stuff for example.

I am not suggesting a new PR, just separate commits will help reviewers per task! Just my opinion on what an atomic commit could be.

}
return result_dict

with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:

@krowvin krowvin Jun 6, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not sure what kind of error handling we have, but when users slam the API with threaded calls there's a chance the API will not respond. Then those calls get retried the 6 times.

I would go about doing some research into the various different ways a futures call could fail and possible add those into our Error handling so it's a little more understanding for the end user what went wrong.

Another possibility is one of these calls fails in some way in the get_ts_ids function and it could potentially cause them all to fail if they have shared state.

There's a few ways you could handle this but most the time it wouldn't fail..

@krowvin krowvin Jun 6, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I just realized you could randomly throw an error to actually test what the threading would do

i.e.

raise Exception("Test!")
Inside the get_ts_ids function - would the rest finish?

And see what happens

@krowvin krowvin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good!

None of these changes are blocking in my opinion! Just suggestions that if you wanted to do something about you could.

@Enovotny Enovotny linked an issue Jun 9, 2025 that may be closed by this pull request
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2025

Copy link
Copy Markdown

@Enovotny Enovotny merged commit 071dc5c into main Jun 9, 2025
8 checks passed
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.

Paging Issue Reduce default pool size to something else

2 participants