Skip to content

Conversation

@thseiler
Copy link
Contributor

@thseiler thseiler commented Jan 27, 2025

Neither the recvmsg() / SO_TIMESTAMPNS method, nor the SIOCGSTAMP / ioctl() method for obtaining the packet timestamp is supported on Windows. This code switches from recvmsg to recvfrom() so that the udp_multicast works on Windows.

To support precise timestamps on Windows, Python would need to expose the WSArecvmsg() function first; see here. This PR is falling back to time.time() for now...

Neither the SO_TIMESTAMPNS / via recvmsg() method, nor the SIOCGSTAMP / ioctl() method for obtaining the packet timestamp is supported on Windows.  This code adds a fallback to datetime, and switches to recvfrom() so that the udp_multicast bus becomes usable on windows.
on windows, the example would otherwise cause an _enter_buffered_busy fatal error, notifier shutdown and bus shutdown are racing eachother...
@thseiler thseiler changed the title support windows udp_multicast interface: support windows Jan 27, 2025
@zariiii9003
Copy link
Collaborator

@thseiler There are two Multicast tests in test/back2back_test.py, that you could enable for Windows. Also, the msgpack dependency not enabled for Windows.

Is there a reason to use datetime intead of time.time()?

@thseiler
Copy link
Contributor Author

@zariiii9003 Thanks a lot for the guidance.

The datetime glitch was me, incorrectly assuming that these timestamps needed local timezone handling...

if (
error.errno == errno.ENOPROTOOPT
or error.errno == errno.EINVAL
or error.errno == errno.WSAEINVAL
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could cause an AttributeError on Linux. You could redefine WSAEINVAL as a module constant.

@unittest.skipUnless(
IS_UNIX and not (IS_CI and IS_OSX),
"only supported on Unix systems (but not on macOS at Travis CI and GitHub Actions)",
(IS_UNIX and not (IS_CI and IS_OSX)) or IS_WINDOWS,
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can replace this with @unittest.skipIf(IS_CI and IS_OSX, ...

@unittest.skipUnless(
IS_UNIX and not (IS_TRAVIS or (IS_CI and IS_OSX)),
"only supported on Unix systems (but not on Travis CI; and not on macOS at GitHub Actions)",
(IS_UNIX and not (IS_TRAVIS or (IS_CI and IS_OSX))) or IS_WINDOWS,
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here, we're not using Travis anymore anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment suggests skipping the UdpMulticast tests on macOS was necessary because of an issue with Travis CI. However, the tests may well work in the .github/workflow macOS environment, and skipping them is no longer necessary. Would you agree this is worth a test?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, that might work. There's still a formatting issue, use black to fix it.

Copy link
Collaborator

@zariiii9003 zariiii9003 left a comment

Choose a reason for hiding this comment

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

Looks good, thank you 👍

@zariiii9003 zariiii9003 merged commit 2bd4758 into hardbyte:main Feb 15, 2025
33 checks passed
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