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

Replace BaseThread's add_task with start_soon #1300

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

davidbrochart
Copy link
Collaborator

This PR replaces a BaseThread's add_task() method with start_soon(). The new name is less confusing as it's the same as in AnyIO, and it allows to start a task in the thread even after the thread has been started.
We also get rid of _IOPubThread, which has no reason to be different than a BaseThread.

(from #1291)

@Carreau
Copy link
Member

Carreau commented Feb 12, 2025

+1 to this, should we merge as s, to make your #1291 smaller ?
Pleas feel free to merge, I don't want to do it if it would make #1291 rebase harder.

@davidbrochart
Copy link
Collaborator Author

I updated the PR with my latest changes in #1291.

Comment on lines 46 to 49
try:
run(self._main)
except Exception:
pass
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to at least log something if there is an exception ? It seems weird to me to swallow exception, but I'll trust you there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True, but I'm not sure if this would play well with threads like iostream, which does something with writing to stdout/stderr?
Maybe the exception could be made available through a method instead?

@Carreau
Copy link
Member

Carreau commented Feb 13, 2025

The lint errors have been fixed on main, and the other failures are the same as main, so +1 to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants