Skip to content
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

Fix blocking calls inside the event loop #383

Merged
merged 2 commits into from
Jun 16, 2024
Merged

Fix blocking calls inside the event loop #383

merged 2 commits into from
Jun 16, 2024

Conversation

rrooggiieerr
Copy link
Contributor

No description provided.

@Hellowlol
Copy link
Collaborator

Have you tested this?

@rrooggiieerr
Copy link
Contributor Author

Of course I did. Are you running into problems?

@rrooggiieerr rrooggiieerr changed the title Lookup timezone without blocking the event loop Fix blocking calls inside the event loop Jun 16, 2024
@rrooggiieerr
Copy link
Contributor Author

I have now also added a fix for the other blocking calls

@Hellowlol Hellowlol merged commit 45b4087 into custom-components:master Jun 16, 2024
3 checks passed
@@ -227,10 +227,17 @@ async def fetch(self, data_type, end_date=None, areas=None):

res = await asyncio.gather(*jobs)

raw = [self._parse_json(i, areas) for i in res]
raw = [await self._async_parse_json(i, areas) for i in res]
Copy link

Choose a reason for hiding this comment

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

It would be more efficient to run the whole list comp in the executor instead of creating a job for each item being iterated

Copy link
Contributor Author

@rrooggiieerr rrooggiieerr Jul 6, 2024

Choose a reason for hiding this comment

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

True! And good catch. Honestly I didn't put to much thought in it as it was my first priority to create a quick fix. Actually, a lot that's happening in the integration should be done in a library, but that is a lot more work for which I don't have time atm

Copy link
Collaborator

Choose a reason for hiding this comment

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

It wasnt supported in the library. Im the one that created PR for the async interface in nordpool package. At the time it wasnt merged and i didnt want to wait. There were issues like using mutable default arguments.

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