-
Notifications
You must be signed in to change notification settings - Fork 387
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(core): fix for Windows platform #681
Conversation
0495776
to
c901aaa
Compare
9e217a7
to
ae07056
Compare
ae07056
to
6364a21
Compare
kazoo/handlers/utils.py
Outdated
# XXX: needed? | ||
# selectors_module.register handle fileobject, do we need the use of fileobj_to_fd()? | ||
# is this test valid for Windows? | ||
# os.fstat(fd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @JetDrag,
Sorry to summon you here. This os.fstat(fd)
call is generating crashes on Windows because the handle is, it seems, invalid. With this call commented out, the crash does not appear (and tests are running fine).
Since you did this implementation, I was wondering if:
- there was a reason using the
fileobj_to_fd()
method instead of directly giving the fileobj toselectors_module.register()
(which seems to be capable of handling fileobj directly)? - you know if the
os.fstat(fd)
test is valid for Windows?
Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second this.
This os.fstat()
does not do anything.
Actually, python3 handles os.stat()
on FD or file just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function fileobj_to_fd
is same as _fileobj_to_fd
function in selectors
module almost except the last second line os.fstat(fd)
.
I did this implementation to simulate the raw select behavior via test case test_selectors_select
, which is modified from Python official test cast test_select
.
If I don't do that, the test cast test_errno
in the test_selectors_select
will fail, because the exception (OSError with errno 22, EINVAL) raise by some selectors.BaseSelector
implementations don't meet the test case requirement:raise OSError with errno 9 (EBADF) when select
meet a closed fd.
Maybe we cloud make some other simulate implementation to make those spec working on the Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/python/cpython/blob/main/Lib/test/test_select.py#L32 test_errno()
for reference.
I do not think we care about this behavior in Kazoo.
Actually, the err conditions with selector when selecting "bad file descriptors" are varied depending on platform and selector implementations (there are threads about this on the Python bug report).
This is here trying to make sure that selectors implementations are all equivalente to select()
behavior and we really can't do that.
IMHO. the only thing we need to do is ensure how Kazoo reacts to a closed FD.
In other words, be it EINVAL
or EBADF
or other, we should raise an uniform Kazoo error (with Python3, we could pass up the original, OS/Implementation dependent Exception).
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It maybe the best solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you both for your thoughts. As suggested, I tried to unify the exceptions that can be raised and catch that in the test_errno()
testcase. That may be too naive, not sure really, so I would love your feedback on this.
@StephenSorriaux is this a draft or ready for review yet? |
@ceache Not really, it is still a draft. I'm just too used to gitlab, which auto marks a PR as draft if "draft" is in the title. |
6364a21
to
5f70985
Compare
What's needed to move this forward? It'd be nice to get this resolved for our Windows users. |
3ff9d53
to
8c747d4
Compare
d462faa
to
623bf83
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me, with the caveat that I haven't actually written/run python on 🪟 in years.
Excellent work! @StephenSorriaux |
623bf83
to
f72b19b
Compare
d5dae3b
d5dae3b
to
d3a688a
Compare
Performing an `os.stat(fd)` on Windows platform generate a crash because the "handler is not valid". `select` already handle this possible case and there is no actual need to perform any kind of check before. This was removed, and the linked test slightly changed.
d3a688a
to
e5becc3
Compare
@ceache @jeffwidman Sorry to resurrect this only now, would appreciate another review if possible and finally merge this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with the caveat that I don't run Windows. But I think the additional confidence of the basic sanity test is enough to be comfortable merging this.
Thank you for your hard work on this!
Thanks for always being around my dear Jeff! |
Fixes #679
Why is this needed?
This fixes an issue with the Windows platform that appeared in the latest 2.9.0 release. This also adds a very basic testing for the Windows platform (only 1 job, for the latest version of Python and the latest version of ZK).
Proposed Changes
os.fstat(fd)
check that is invalid on Windows platformtest_selector_select
testgevent
seems broken on Windows so... skipped it): only 1 job because I don't feel like we need to re-test every version of Python/ZK for WindowsDoes this PR introduce any breaking change?
Nah.