本文整理汇总了Python中twisted.internet.abstract.FileDescriptor类的典型用法代码示例。如果您正苦于以下问题:Python FileDescriptor类的具体用法?Python FileDescriptor怎么用?Python FileDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:dnozay,项目名称:rdpy,代码行数:7,代码来源:layer.py
示例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 = []
开发者ID:azbarcea,项目名称:calendarserver,代码行数:7,代码来源:sendfdport.py
示例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)
开发者ID:alexsunday,项目名称:pyvpn,代码行数:7,代码来源:server.py
示例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
开发者ID:buben19,项目名称:twistedinput,代码行数:8,代码来源:device.py
示例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)
开发者ID:Valodim,项目名称:irclogd,代码行数:9,代码来源:fifo.py
示例6: _simpleSetup
def _simpleSetup(self):
reactor = self.buildReactor()
client, server = self._connectedPair()
fd = FileDescriptor(reactor)
fd.fileno = client.fileno
return reactor, fd, server
开发者ID:svpcom,项目名称:twisted-cdeferred,代码行数:9,代码来源:test_fdset.py
示例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)
开发者ID:alessandrod,项目名称:cattivo,代码行数:9,代码来源:server.py
示例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)
开发者ID:0004c,项目名称:VTK,代码行数:10,代码来源:_newtls.py
示例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)
开发者ID:Valodim,项目名称:irclogd,代码行数:10,代码来源:fifo.py
示例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.")
开发者ID:0004c,项目名称:VTK,代码行数:10,代码来源:inotify.py
示例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 = []
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:10,代码来源:sendfdport.py
示例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)
开发者ID:0004c,项目名称:VTK,代码行数:10,代码来源:_newtls.py
示例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)
开发者ID:0004c,项目名称:VTK,代码行数:11,代码来源:_newtls.py
示例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)
开发者ID:0004c,项目名称:VTK,代码行数:11,代码来源:_newtls.py
示例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)
开发者ID:Juxi,项目名称:OpenSignals,代码行数:12,代码来源:_newtls.py
示例16: startWriting
def startWriting(self):
"""
Start waiting for write availability. Will raise L{OSError} with
errno == ENXIO, if other end hasn't been opened (see fifo(7)).
@raise OSError: if other end hasn't been opened (errno == ENXIO)
"""
if self.connected:
FileDescriptor.startWriting(self)
return
self._fd = os.open(self.path.path, os.O_WRONLY | os.O_NONBLOCK)
self.connected = 1
FileDescriptor.startWriting(self)
开发者ID:Valodim,项目名称:irclogd,代码行数:13,代码来源:fifo.py
示例17: registerProducer
def registerProducer(self, producer, streaming):
"""
Register a producer.
If TLS is enabled, the TLS connection handles this.
"""
if self.TLS:
# Registering a producer before we're connected shouldn't be a
# problem. If we end up with a write(), that's already handled in
# the write() code above, and there are no other potential
# side-effects.
self.protocol.registerProducer(producer, streaming)
else:
FileDescriptor.registerProducer(self, producer, streaming)
开发者ID:0004c,项目名称:VTK,代码行数:14,代码来源:_newtls.py
示例18: __new__
def __new__(cls, *args, **kwargs):
obj = getattr(cls, '_instance_', None)
if obj is not None:
return obj
else:
obj = super(INotify, cls).__new__(cls, *args, **kwargs)
# Check inotify support by checking for the required functions
obj.libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c'))
if len([function for function in "inotify_add_watch inotify_init inotify_rm_watch".split() if hasattr(obj.libc, function)]) == 3:
obj.inotify_init = obj.libc.inotify_init
obj.inotify_add_watch = obj.libc_inotify_add_watch
obj.inotify_rm_watch = obj.libc_inotify_rm_watch
else:
print("inotify.py - can't use libc6, 2.4 or higher needed")
import platform
if platform.system() != 'Linux':
raise SystemError("unknown system '%r', INotify support disabled" % platform.uname())
machine = platform.machine()
try:
obj._init_syscall_id = _inotify_syscalls[machine][0]
obj._add_watch_syscall_id = _inotify_syscalls[machine][1]
obj._rm_watch_syscall_id = _inotify_syscalls[machine][2]
obj.inotify_init = obj._inotify_init
obj.inotify_add_watch = obj._inotify_add_watch
obj.inotify_rm_watch = obj._inotify_rm_watch
except:
raise SystemError("unknown system '%s', INotify support disabled" % machine)
FileDescriptor.__init__(obj)
obj._fd = obj.inotify_init()
if obj._fd < 0:
raise SystemError("INotify initialization error.")
fdesc.setNonBlocking(obj._fd)
reactor.addReader(obj)
obj._buffer = ''
# Mapping from wds to Watch objects
obj._watchpoints = {}
# Mapping from paths to wds
obj._watchpaths = {}
cls._instance_ = obj
return obj
开发者ID:BlackHole,项目名称:coherence,代码行数:45,代码来源:inotify.py
示例19: doWrite
def doWrite(self):
result = FileDescriptor.doWrite(self)
if self._tlsWaiting is not None:
if not self.dataBuffer and not self._tempDataBuffer:
waiting = self._tlsWaiting
self._tlsWaiting = None
self.startTLS(waiting.context, waiting.extra)
self.writeSequence(waiting.bufferedData)
return result
开发者ID:antong,项目名称:twisted,代码行数:9,代码来源:_oldtls.py
示例20: __new__
def __new__(cls, *args, **kwargs):
obj = getattr(cls,'_instance_',None)
if obj is not None:
return obj
else:
if ctypes == None:
raise SystemError, "ctypes not detected on this system, INotify support disabled"
obj = super(INotify, cls).__new__(cls, *args, **kwargs)
try:
obj.libc = ctypes.CDLL("libc.so.6")
except:
raise SystemError, "libc not found, INotify support disabled"
try:
obj.inotify_init = obj.libc.inotify_init
#print "horray, we have a libc with inotify support"
obj.inotify_add_watch = obj.libc_inotify_add_watch
obj.inotify_rm_watch = obj.libc_inotify_rm_watch
except:
import platform
machine = platform.machine()
try:
obj._init_syscall_id = _inotify_syscalls[machine][0]
obj._add_watch_syscall_id = _inotify_syscalls[machine][1]
obj._rm_watch_syscall_id = _inotify_syscalls[machine][2]
except:
raise SystemError, "unknown system '%s', INotify support disabled" % machine
FileDescriptor.__init__(obj)
obj._fd = obj.inotify_init()
if obj._fd < 0:
raise SystemError, "INotify support not detected on this system."
fdesc.setNonBlocking(obj._fd) # FIXME do we need this?
reactor.addReader(obj)
obj._buffer = ''
obj._watchpoints = {}
cls._instance_ = obj
return obj
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:44,代码来源:inotify.py
注:本文中的twisted.internet.abstract.FileDescriptor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论