Skip to content

[BREAKING CHANGE] Fixes: #90 Remove idle emulation from asyncio event loop #541

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

Merged
merged 4 commits into from
Apr 21, 2023

Conversation

penguinolog
Copy link
Collaborator

Re-implement abandoned PR #418

  • Fix "not hashable AttrSpec" and it's instance creation price (use __slots__) AttrSpec instances may be created in huge amount, with slots this process consume less resources.
  • Terminal is always created with event loop, if not provided -> SelectEventLoop is used
  • Fixed TornadoEventLoop & AsyncioEventLoop logic (Tornado IOLoop is asyncio based)

For extra details see original PR.

Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment
  • I've included docstrings and/or documentation and/or examples for my code (if this is a new feature)

…ent loop

Re-implement abandoned PR urwid#418
* Fix "not hashable `AttrSpec`" and it's instance creation price (use `__slots__`)
  `AttrSpec` instances may be created in huge amount,
  with slots this process consume less resources.
* `Terminal` is always created with event loop,
  if not provided -> `SelectEventLoop` is used
* Fixed `TornadoEventLoop` & `AsyncioEventLoop` logic
  (Tornado IOLoop is asyncio based)

For extra details see original PR.
@penguinolog penguinolog changed the title [BREAKING CHANGE] Fix: #90 Remove idle emulation from asyncio event loop [BREAKING CHANGE] Fixes: #90 Remove idle emulation from asyncio event loop Apr 19, 2023
@penguinolog penguinolog linked an issue Apr 19, 2023 that may be closed by this pull request

Instance is mutable -> use ID component.
"""
return hash((self.__class__, self._value, id(self)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

if _value is mutable should it be used for computing a __hash__? Won't this cause a problem if it's used as a key in a dict then modified?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's made like done by "unsafe hash" in python data classes. Making instance id specific (not recalculated) hash maybe also solution.
Hash is required for terminal example app.

Copy link
Collaborator

Choose a reason for hiding this comment

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

interesting, I didn't know about that. Is it worth mentioning this expected unsafe behavior or the reason for adding __hash__ in the docstring?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll add mention in docstring and will recheck repository for mutation calls. If will be possible - will change it to immutable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Immutable AttrSpec would be a good change

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@wardi
Copy link
Collaborator

wardi commented Apr 19, 2023

does this change allow handling multiple input/resize events before the screen is redrawn so that the application can "catch up" quickly?

@penguinolog
Copy link
Collaborator Author

does this change allow handling multiple input/resize events before the screen is redrawn so that the application can "catch up" quickly?

In my test runs it was quick enough during filesystem browse and no issues on widget replacement.

@wardi
Copy link
Collaborator

wardi commented Apr 19, 2023

A test I used to do was steadily drag the terminal window size so the input would fill up with resize events. If the redraw is happening between each event then after you stop resizing the application will take an arbitrarily long time to catch up and be responsive again. If the redraw happens at the end of handling input events then the application will be almost immediately responsive.

@penguinolog
Copy link
Collaborator Author

A test I used to do was steadily drag the terminal window size so the input would fill up with resize events. If the redraw is happening between each event then after you stop resizing the application will take an arbitrarily long time to catch up and be responsive again. If the redraw happens at the end then the application will be almost immediately responsive.

For me after ~30 seconds of nonstop resize terminal example worked immediately on AsyncioEventLoop and TornadoEventLoop.

Co-authored-by: Ian Ward <ian@excess.org>
@penguinolog penguinolog merged commit 350ee5c into urwid:master Apr 21, 2023
@rndusr rndusr mentioned this pull request May 6, 2023
lunar-mining added a commit to darkrenaissance/darkfi that referenced this pull request Oct 25, 2023
upgrading urwid to 2.2.0 breaks dnet in two ways:

* ui is not visible unless the terminal is in focus
* the screen is not redrawing correctly- contains artifacts from previous draw.

it may have to do with this breaking change that was added to 2.2.0:

urwid/urwid#541

but i am not sure yet, investigating.
parazyd pushed a commit to darkrenaissance/darkfi that referenced this pull request Oct 26, 2023
upgrading urwid to 2.2.0 breaks dnet in two ways:

* ui is not visible unless the terminal is in focus
* the screen is not redrawing correctly- contains artifacts from previous draw.

it may have to do with this breaking change that was added to 2.2.0:

urwid/urwid#541

but i am not sure yet, investigating.
parazyd pushed a commit to darkrenaissance/darkfi that referenced this pull request Oct 26, 2023
upgrading urwid to 2.2.0 breaks dnet in two ways:

* ui is not visible unless the terminal is in focus
* the screen is not redrawing correctly- contains artifacts from previous draw.

it may have to do with this breaking change that was added to 2.2.0:

urwid/urwid#541

but i am not sure yet, investigating.
@penguinolog penguinolog deleted the idle_emulation_drop branch January 19, 2024 08:18
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.

High CPU load with AsyncioEventLoop
2 participants