Skip to content

Commit

Permalink
fix check on other platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaraditya303 authored Oct 24, 2022
1 parent f090e8d commit d6c77cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Lib/asyncio/selector_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
HAVE_SENDMSG = hasattr(socket.socket, 'sendmsg')

if HAVE_SENDMSG:
SC_IOV_MAX = os.sysconf('SC_IOV_MAX')
try:
SC_IOV_MAX = os.sysconf('SC_IOV_MAX')
except OSError:
# Fallback to send
HAVE_SENDMSG = False

def _test_selector_event(selector, fd, event):
# Test if the selector is monitoring 'event' events
Expand Down
17 changes: 9 additions & 8 deletions Lib/test/test_asyncio/test_selector_events.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
"""Tests for selector_events.py"""

import collections
import sys
import selectors
import socket
import sys
import unittest
from asyncio import selector_events
from unittest import mock

try:
import ssl
except ImportError:
ssl = None

import asyncio
from asyncio.selector_events import BaseSelectorEventLoop
from asyncio.selector_events import _SelectorTransport
from asyncio.selector_events import _SelectorSocketTransport
from asyncio.selector_events import _SelectorDatagramTransport
from asyncio.selector_events import (BaseSelectorEventLoop,
_SelectorDatagramTransport,
_SelectorSocketTransport,
_SelectorTransport)
from test.test_asyncio import utils as test_utils


MOCK_ANY = mock.ANY


Expand Down Expand Up @@ -746,7 +747,7 @@ def test_write_sendmsg_no_data(self):
self.assertFalse(self.sock.sendmsg.called)
self.assertEqual(list_to_buffer([b'data']), transport._buffer)

@unittest.skipUnless(hasattr(socket.socket, 'sendmsg'), 'no sendmsg')
@unittest.skipUnless(selector_events.HAVE_SENDMSG, 'no sendmsg')
def test_write_sendmsg_full(self):
data = memoryview(b'data')
self.sock.sendmsg = mock.Mock()
Expand All @@ -759,7 +760,7 @@ def test_write_sendmsg_full(self):
self.assertTrue(self.sock.sendmsg.called)
self.assertFalse(self.loop.writers)

@unittest.skipUnless(hasattr(socket.socket, 'sendmsg'), 'no sendmsg')
@unittest.skipUnless(selector_events.HAVE_SENDMSG, 'no sendmsg')
def test_write_sendmsg_partial(self):

data = memoryview(b'data')
Expand Down

0 comments on commit d6c77cd

Please sign in to comment.