本文整理汇总了Python中twisted.internet.abstract.FileDescriptor类的典型用法代码示例。如果您正苦于以下问题:Python FileDescriptor类的具体用法?Python FileDescriptor怎么用?Python FileDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: close
def close(self):
"""
@summary: Close raw layer
Use File descriptor directly to not use TLS close
Because is bugged
"""
FileDescriptor.loseConnection(self.transport)
示例2: __init__
def __init__(self, dispatcher, skt):
FileDescriptor.__init__(self, dispatcher.reactor)
self.status = None
self.dispatcher = dispatcher
self.skt = skt # XXX needs to be set non-blocking by somebody
self.fileno = skt.fileno
self.outgoingSocketQueue = []
示例3: connectionLost
def connectionLost(self, reason):
if self.tunfd >= 0:
try:
os.close(self.tunfd)
except OSError as _:
logger.error("cannot close tunfd")
FileDescriptor.connectionLost(self, reason)
示例4: __init__
def __init__(self, protocol, device, reactor = None):
FileDescriptor.__init__(self, reactor = reactor)
self.protocol = protocol
self.protocol.makeConnection(self)
self.__device = open(device, "r+w+")
self.reading = False
self.backToReading = False
示例5: connectionLost
def connectionLost(self, reason):
"""
The connection was lost.
"""
FileDescriptor.connectionLost(self, reason)
self.protocol.connectionLost(reason)
self.connected = 0
if self._fd is not None:
os.close(self._fd)
示例6: _simpleSetup
def _simpleSetup(self):
reactor = self.buildReactor()
client, server = self._connectedPair()
fd = FileDescriptor(reactor)
fd.fileno = client.fileno
return reactor, fd, server
示例7: __init__
def __init__(self, group, reactor=None):
FileDescriptor.__init__(self, reactor)
self.wrapper = NFLog()
self.wrapper.open()
self.wrapper.bindProtocolFamily(AF_INET)
self.group = group
self.wrapper.bindGroup(group)
self.wrapper.setMode(NFULNL_COPY_PACKET, 0xFFFF)
self.wrapper.setCallback(self.nflogCallback)
示例8: write
def write(self, bytes):
"""
Write some bytes to this connection, passing them through a TLS layer if
necessary, or discarding them if the connection has already been lost.
"""
if self.TLS:
if self.connected:
self.protocol.write(bytes)
else:
FileDescriptor.write(self, bytes)
示例9: startReading
def startReading(self):
"""
Start waiting for read availability
"""
if self.connected:
FileDescriptor.startReading(self)
return
self._fd = os.open(self.path, os.O_RDONLY | os.O_NONBLOCK)
self.connected = 1
FileDescriptor.startReading(self)
示例10: connectionLost
def connectionLost(self, reason):
"""
Release the inotify file descriptor and do the necessary cleanup
"""
FileDescriptor.connectionLost(self, reason)
if self._fd >= 0:
try:
os.close(self._fd)
except OSError, e:
log.err(e, "Couldn't close INotify file descriptor.")
示例11: __init__
def __init__(self, dispatcher, inSocket, outSocket, status, slavenum):
FileDescriptor.__init__(self, dispatcher.reactor)
self.status = status
self.slavenum = slavenum
self.dispatcher = dispatcher
self.inSocket = inSocket
self.outSocket = outSocket # XXX needs to be set non-blocking by somebody
self.fileno = outSocket.fileno
self.outgoingSocketQueue = []
self.pendingCloseSocketQueue = []
示例12: unregisterProducer
def unregisterProducer(self):
"""
Unregister a producer.
If TLS is enabled, the TLS connection handles this.
"""
if self.TLS:
self.protocol.unregisterProducer()
else:
FileDescriptor.unregisterProducer(self)
示例13: loseConnection
def loseConnection(self):
"""
Close this connection after writing all pending data.
If TLS has been negotiated, perform a TLS shutdown.
"""
if self.TLS:
if self.connected and not self.disconnecting:
self.protocol.loseConnection()
else:
FileDescriptor.loseConnection(self)
示例14: writeSequence
def writeSequence(self, iovec):
"""
Write some bytes to this connection, scatter/gather-style, passing them
through a TLS layer if necessary, or discarding them if the connection
has already been lost.
"""
if self.TLS:
if self.connected:
self.protocol.writeSequence(iovec)
else:
FileDescriptor.writeSequence(self, iovec)
示例15: write
def write(self, bytes):
"""
Write some bytes to this connection, passing them through a TLS layer if
necessary, or discarding them if the connection has already been lost.
"""
if self.TLS:
if self.connected:
self.protocol.write(bytes)
elif self._tlsWaiting is not None:
self._tlsWaiting.bufferedData.append(bytes)
else:
FileDescriptor.write(self, bytes)