本文整理汇总了Python中errno.ESHUTDOWN属性的典型用法代码示例。如果您正苦于以下问题:Python errno.ESHUTDOWN属性的具体用法?Python errno.ESHUTDOWN怎么用?Python errno.ESHUTDOWN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类errno
的用法示例。
在下文中一共展示了errno.ESHUTDOWN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: poll
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def poll(self, event, timeout):
if self.state.SHUTDOWN:
raise err.Error(errno.ESHUTDOWN)
if event == "recv":
if self.state.ESTABLISHED or self.state.CLOSE_WAIT:
rcvd_pdu = super(DataLinkConnection, self).poll(event, timeout)
if self.state.ESTABLISHED or self.state.CLOSE_WAIT:
return isinstance(rcvd_pdu, pdu.Information)
elif event == "send":
if self.state.ESTABLISHED:
if super(DataLinkConnection, self).poll(event, timeout):
return self.state.ESTABLISHED
return False
elif event == "acks":
with self.acks_ready:
if not self.acks_recvd > 0:
self.acks_ready.wait(timeout)
if self.acks_recvd > 0:
self.acks_recvd = self.acks_recvd - 1
return True
return False
else:
raise err.Error(errno.EINVAL)
示例2: test_recv
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def test_recv(self, tco):
pdu = nfc.llcp.pdu.UnnumberedInformation(1, 1, HEX('1122'))
assert tco.enqueue(pdu) is True
assert tco.recv() == pdu
threading.Timer(0.01, tco.close).start()
with pytest.raises(nfc.llcp.Error) as excinfo:
tco.recv()
assert excinfo.value.errno == errno.EPIPE
with pytest.raises(nfc.llcp.Error) as excinfo:
tco.recv()
assert excinfo.value.errno == errno.ESHUTDOWN
# =============================================================================
# Logical Data Link
# =============================================================================
示例3: send
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def send(self, input):
input = to_bytes(input)
if not self.stdin:
return None
try:
x = msvcrt.get_osfhandle(self.stdin.fileno())
(errCode, written) = WriteFile(x, input)
except ValueError:
return self._close('stdin')
except (subprocess.pywintypes.error, Exception) as why:
if why.args[0] in (109, errno.ESHUTDOWN):
return self._close('stdin')
raise
return written
示例4: _recv
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def _recv(self, which, maxsize):
conn, maxsize = self.get_conn_maxsize(which, maxsize)
if conn is None:
return None
try:
x = msvcrt.get_osfhandle(conn.fileno())
(read, nAvail, nMessage) = PeekNamedPipe(x, 0)
if maxsize < nAvail:
nAvail = maxsize
if nAvail > 0:
(errCode, read) = ReadFile(x, nAvail, None)
except ValueError:
return self._close(which)
except (subprocess.pywintypes.error, Exception) as why:
if why.args[0] in (109, errno.ESHUTDOWN):
return self._close(which)
raise
# if self.universal_newlines:
# read = self._translate_newlines(read)
return read
示例5: _recv
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def _recv(self, which, maxsize):
conn, maxsize = self.get_conn_maxsize(which, maxsize)
if conn is None:
return None
try:
x = msvcrt.get_osfhandle(conn.fileno())
(read, nAvail, nMessage) = PeekNamedPipe(x, 0)
if maxsize < nAvail:
nAvail = maxsize
if nAvail > 0:
(errCode, read) = ReadFile(x, nAvail, None)
except (ValueError, NameError):
return self._close(which)
except (subprocess.pywintypes.error, Exception), why:
if why[0] in (109, errno.ESHUTDOWN):
return self._close(which)
raise
示例6: _recv
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def _recv(self, which, maxsize):
conn, maxsize = self.get_conn_maxsize(which, maxsize)
if conn is None:
return None
try:
x = msvcrt.get_osfhandle(conn.fileno())
(read, nAvail, nMessage) = PeekNamedPipe(x, 0)
if maxsize < nAvail:
nAvail = maxsize
if nAvail > 0:
(errCode, read) = ReadFile(x, nAvail, None)
except ValueError:
return self._close(which)
except (subprocess.pywintypes.error, Exception) as why:
if why[0] in (109, errno.ESHUTDOWN):
return self._close(which)
raise
#if self.universal_newlines:
# read = self._translate_newlines(read)
return read
示例7: _recv
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def _recv(self, which, maxsize):
conn, maxsize = self.get_conn_maxsize(which, maxsize)
if conn is None:
return None
try:
x = msvcrt.get_osfhandle(conn.fileno())
(read, nAvail, nMessage) = PeekNamedPipe(x, 0)
if maxsize < nAvail:
nAvail = maxsize
if nAvail > 0:
(errCode, read) = ReadFile(x, nAvail, None)
except ValueError:
return self._close(which)
except (subprocess.pywintypes.error, Exception), why:
if why[0] in (109, errno.ESHUTDOWN):
return self._close(which)
raise
#if self.universal_newlines:
# read = self._translate_newlines(read)
示例8: _recv
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def _recv(self, which, maxsize):
conn, maxsize = self.get_conn_maxsize(which, maxsize)
read = ""
if conn is None:
return None
try:
fd = conn.fileno()
handle = get_osfhandle(fd)
avail = c_ulong(0)
PeekNamedPipe(handle, None, 0, None, byref(avail), None)
nAvail = avail.value
if maxsize < nAvail:
nAvail = maxsize
if nAvail > 0:
read = os.read(fd, nAvail)
except ValueError:
return self._close(which)
except (subprocess.pywintypes.error, Exception), why:
if why[0] in (109, errno.ESHUTDOWN):
return self._close(which)
raise
示例9: _recv
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def _recv(self, which, maxsize):
conn, maxsize = self.get_conn_maxsize(which, maxsize)
if conn is None:
return None
try:
x = msvcrt.get_osfhandle(conn.fileno())
(read, nAvail, nMessage) = PeekNamedPipe(x, 0)
if maxsize < nAvail:
nAvail = maxsize
if nAvail > 0:
(errCode, read) = ReadFile(x, nAvail, None)
except ValueError:
return self._close(which)
except (subprocess.pywintypes.error, Exception):
if geterror()[0] in (109, errno.ESHUTDOWN):
return self._close(which)
raise
if self.universal_newlines:
# Translate newlines. For Python 3.x assume read is text.
# If bytes then another solution is needed.
read = read.replace("\r\n", "\n").replace("\r", "\n")
return read
示例10: setsockopt
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def setsockopt(self, option, value):
if self.state.SHUTDOWN:
raise err.Error(errno.ESHUTDOWN)
super(RawAccessPoint, self).setsockopt(option, value)
示例11: getsockopt
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def getsockopt(self, option):
if self.state.SHUTDOWN:
raise err.Error(errno.ESHUTDOWN)
return super(RawAccessPoint, self).getsockopt(option)
示例12: send
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def send(self, send_pdu, flags):
if self.state.SHUTDOWN:
raise err.Error(errno.ESHUTDOWN)
log.debug("{0} send {1}".format(str(self), send_pdu))
super(RawAccessPoint, self).send(send_pdu, flags)
return self.state.ESTABLISHED is True
示例13: recv
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def recv(self):
if self.state.SHUTDOWN:
raise err.Error(errno.ESHUTDOWN)
try:
return super(RawAccessPoint, self).recv()
except IndexError:
raise err.Error(errno.EPIPE)
示例14: connect
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def connect(self, dest):
if self.state.SHUTDOWN:
raise err.Error(errno.ESHUTDOWN)
with self.lock:
self.peer = dest
return self.peer > 0
示例15: sendto
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESHUTDOWN [as 别名]
def sendto(self, message, dest, flags):
if self.state.SHUTDOWN:
raise err.Error(errno.ESHUTDOWN)
if self.peer and dest != self.peer:
raise err.Error(errno.EDESTADDRREQ)
if len(message) > self.send_miu:
raise err.Error(errno.EMSGSIZE)
send_pdu = pdu.UnnumberedInformation(dest, self.addr, data=message)
super(LogicalDataLink, self).send(send_pdu, flags)
return self.state.ESTABLISHED is True