本文整理汇总了Python中errno.WSAENOTSOCK属性的典型用法代码示例。如果您正苦于以下问题:Python errno.WSAENOTSOCK属性的具体用法?Python errno.WSAENOTSOCK怎么用?Python errno.WSAENOTSOCK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类errno
的用法示例。
在下文中一共展示了errno.WSAENOTSOCK属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalidDescriptor
# 需要导入模块: import errno [as 别名]
# 或者: from errno import WSAENOTSOCK [as 别名]
def test_invalidDescriptor(self):
"""
An implementation of L{IReactorSocket.adoptStreamPort} raises
L{socket.error} if passed an integer which is not associated with a
socket.
"""
reactor = self.buildReactor()
probe = socket.socket()
fileno = probe.fileno()
probe.close()
exc = self.assertRaises(
socket.error,
reactor.adoptStreamPort, fileno, socket.AF_INET, ServerFactory())
if platform.isWindows() and _PY3:
self.assertEqual(exc.args[0], errno.WSAENOTSOCK)
else:
self.assertEqual(exc.args[0], errno.EBADF)
示例2: getHandleErrorCode
# 需要导入模块: import errno [as 别名]
# 或者: from errno import WSAENOTSOCK [as 别名]
def getHandleErrorCode(self):
"""
Return the argument L{SSL.Error} will be constructed with for this
case. This is basically just a random OpenSSL implementation detail.
It would be better if this test worked in a way which did not require
this.
"""
# Windows 2000 SP 4 and Windows XP SP 2 give back WSAENOTSOCK for
# SSL.Connection.write for some reason. The twisted.protocols.tls
# implementation of IReactorSSL doesn't suffer from this imprecation,
# though, since it is isolated from the Windows I/O layer (I suppose?).
# If test_properlyCloseFiles waited for the SSL handshake to complete
# and performed an orderly shutdown, then this would probably be a
# little less weird: writing to a shutdown SSL connection has a more
# well-defined failure mode (or at least it should).
name = fullyQualifiedName(getClass(reactor))
if platform.getType() == 'win32' and name != self._iocp:
return errno.WSAENOTSOCK
# This is terribly implementation-specific.
return [('SSL routines', 'SSL_write', 'protocol is shutdown')]
示例3: getHandleErrorCode
# 需要导入模块: import errno [as 别名]
# 或者: from errno import WSAENOTSOCK [as 别名]
def getHandleErrorCode(self):
"""
Return the errno expected to result from writing to a closed
platform socket handle.
"""
# Windows and Python 3: returns WSAENOTSOCK
# Windows and Python 2: returns EBADF
# Linux, FreeBSD, Mac OS X: returns EBADF
if platform.isWindows() and _PY3:
return errno.WSAENOTSOCK
return errno.EBADF
示例4: getHandleErrorCode
# 需要导入模块: import errno [as 别名]
# 或者: from errno import WSAENOTSOCK [as 别名]
def getHandleErrorCode(self):
"""
Return the argument L{OpenSSL.SSL.Error} will be constructed with for
this case. This is basically just a random OpenSSL implementation
detail. It would be better if this test worked in a way which did not
require this.
"""
# Windows 2000 SP 4 and Windows XP SP 2 give back WSAENOTSOCK for
# SSL.Connection.write for some reason. The twisted.protocols.tls
# implementation of IReactorSSL doesn't suffer from this imprecation,
# though, since it is isolated from the Windows I/O layer (I suppose?).
# If test_properlyCloseFiles waited for the SSL handshake to complete
# and performed an orderly shutdown, then this would probably be a
# little less weird: writing to a shutdown SSL connection has a more
# well-defined failure mode (or at least it should).
# So figure out if twisted.protocols.tls is in use. If it can be
# imported, it should be.
if requireModule('twisted.protocols.tls') is None:
# It isn't available, so we expect WSAENOTSOCK if we're on Windows.
if platform.getType() == 'win32':
return errno.WSAENOTSOCK
# Otherwise, we expect an error about how we tried to write to a
# shutdown connection. This is terribly implementation-specific.
return [('SSL routines', 'SSL_write', 'protocol is shutdown')]
示例5: getHandleErrorCodeMatcher
# 需要导入模块: import errno [as 别名]
# 或者: from errno import WSAENOTSOCK [as 别名]
def getHandleErrorCodeMatcher(self):
"""
Return a L{hamcrest.core.matcher.Matcher} that matches the
errno expected to result from writing to a closed platform
socket handle.
"""
# Windows and Python 3: returns WSAENOTSOCK
# Windows and Python 2: returns EBADF
# Linux, FreeBSD, macOS: returns EBADF
if platform.isWindows() and _PY3:
return hamcrest.equal_to(errno.WSAENOTSOCK)
return hamcrest.equal_to(errno.EBADF)
示例6: start_open_files_server
# 需要导入模块: import errno [as 别名]
# 或者: from errno import WSAENOTSOCK [as 别名]
def start_open_files_server(self):
self.open_files_server.setsockopt(socket.SOL_SOCKET,
socket.SO_REUSEADDR, 1)
port = select_port(default_port=OPEN_FILES_PORT)
CONF.set('main', 'open_files_port', port)
self.open_files_server.bind(('127.0.0.1', port))
self.open_files_server.listen(20)
while 1: # 1 is faster than True
try:
req, dummy = self.open_files_server.accept()
except socket.error as e:
# See Issue 1275 for details on why errno EINTR is
# silently ignored here.
eintr = errno.WSAEINTR if os.name == 'nt' else errno.EINTR
# To avoid a traceback after closing on Windows
if e.args[0] == eintr:
continue
# handle a connection abort on close error
enotsock = (errno.WSAENOTSOCK if os.name == 'nt'
else errno.ENOTSOCK)
if e.args[0] in [errno.ECONNABORTED, enotsock]:
return
raise
fname = req.recv(1024)
fname = fname.decode('utf-8')
self.sig_open_external_file.emit(fname)
req.sendall(b' ')
# ---- Quit and restart, and reset spyder defaults