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

Catch and expound upon the py38 proactor add_reader() not implemented exception #88

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

altendky
Copy link
Member

@altendky altendky commented Feb 21, 2020

@altendky
Copy link
Member Author

Hopefully there's some useful code here though I suspect it's not all that sensible. A bit tired etc but wanted to get something in place as a reference to consider.

@altendky altendky changed the title Catch and expound upon the py38 proactor add_reader() not implemented exception [WIP] Catch and expound upon the py38 proactor add_reader() not implemented exception Feb 21, 2020
six.raise_from(
value=AddReaderNotImplementedError.build(),
from_value=e,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Needs some else: raise otherwise you suppress the exception

Copy link
Member Author

Choose a reason for hiding this comment

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

Like I said, late and sleepy... :| Will do.

"Failed to install asyncio reactor. The proactor was"
" used and is lacking the needed `.add_reader()` method"
" as of Python 3.8 on Windows."
" https://twistedmatrix.com/trac/ticket/9766"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This error message could use some love. The proactor doesn't implement add_reader, period, not just on 3.8.

More to the point, why the single-case exception? I think it would be better to just raise NotImplementedError with that message in the except block.

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 proactor might implement .add_reader() in the future. But sure, we know for <= 3.8.1.

I like specific exceptions and not incidentally catching those I don't intend by libraries providing their own. Look at the hoops to figure out if it is the NotImplementedError from .add_reader(). But I did consider inheriting from NotImplementedError since it is a raise from situation.

_, _, traceback_object = sys.exc_info()
stack_summary = traceback.extract_tb(traceback_object)
source_function_name = stack_summary[-1].name
event_loop = asyncio.get_event_loop()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm -1 on this. I realize you're trying to scope it to this specific case to avoid a lying error message, but IMO this relies way too heavily on implementation details.

I think preserving the traceback is enough for context, and then just change the error to say what we think happened... Phrased like "If you're on windows and python 3.8+, you might need to..." perhaps.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps my head was still in the 'identify the issue and resolve it' mode where you want to be sure. Given this is just going to refine the error message which can be worded as a guess it is more acceptable to... guess.

Maybe instead of more granular NotImplementedErrord raisers should include the function object raising it for identification.

Plus I suppose back to 'this is really twisted's problem to address' justifying less effort.

Copy link
Collaborator

@cdunklau cdunklau left a comment

Choose a reason for hiding this comment

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

I think a simpler detection routine would be better.

@altendky
Copy link
Member Author

I'll take a pass responding to the rest later.

@altendky
Copy link
Member Author

Well, I responded already... but a pass of code change responses.

@altendky
Copy link
Member Author

altendky commented Mar 4, 2020

Wait, I'm holding the ball... :[

@altendky altendky marked this pull request as draft July 20, 2020 17:34
@altendky altendky changed the title [WIP] Catch and expound upon the py38 proactor add_reader() not implemented exception Catch and expound upon the py38 proactor add_reader() not implemented exception Jul 20, 2020
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