Skip to content

Commit fd1ed40

Browse files
only import ioctl on linux
1 parent 9956d8b commit fd1ed40

File tree

1 file changed

+4
-10
lines changed
  • can/interfaces/udp_multicast

1 file changed

+4
-10
lines changed

can/interfaces/udp_multicast/bus.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,9 @@
1414

1515
from .utils import check_msgpack_installed, pack_message, unpack_message
1616

17-
ioctl_supported = True
18-
19-
try:
17+
is_linux = platform.system() == "Linux"
18+
if is_linux:
2019
from fcntl import ioctl
21-
except ModuleNotFoundError: # Missing on Windows
22-
ioctl_supported = False
23-
pass
24-
25-
# All ioctls aren't supported on MacOS.
26-
is_macos = platform.system() == "Darwin"
2720

2821
log = logging.getLogger(__name__)
2922

@@ -408,7 +401,8 @@ def recv(
408401
self.max_buffer
409402
)
410403

411-
if ioctl_supported and not is_macos:
404+
if is_linux:
405+
# This ioctl isn't supported on Darwin & Windows.
412406
result_buffer = ioctl(
413407
self._socket.fileno(),
414408
SIOCGSTAMP,

0 commit comments

Comments
 (0)