本文整理汇总了Python中twisted.internet.reactor.removeReader函数的典型用法代码示例。如果您正苦于以下问题:Python removeReader函数的具体用法?Python removeReader怎么用?Python removeReader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了removeReader函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connectionMade
def connectionMade(self):
sockFD = self.transport.fileno()
childFDs = {0: sockFD, 1: sockFD}
if self.factory.stderrFile:
childFDs[2] = self.factory.stderrFile.fileno()
# processes run by inetd expect blocking sockets
# FIXME: maybe this should be done in process.py? are other uses of
# Process possibly affected by this?
fdesc.setBlocking(sockFD)
if childFDs.has_key(2):
fdesc.setBlocking(childFDs[2])
service = self.factory.service
uid = service.user
gid = service.group
# don't tell Process to change our UID/GID if it's what we
# already are
if uid == os.getuid():
uid = None
if gid == os.getgid():
gid = None
process.Process(None, service.program, service.programArgs, os.environ,
None, None, uid, gid, childFDs)
reactor.removeReader(self.transport)
reactor.removeWriter(self.transport)
示例2: close
def close(self):
reactor.removeReader(self)
self.sock.setblocking(True)
self.sock.close()
self.sock = None
if self.address.lower() in SCOReader.clients:
del SCOReader.clients[self.address.lower()]
示例3: _delegateFD
def _delegateFD(self):
# Take out the fd from twisted reactor and pass it to element
# using it
# See http://twistedmatrix.com/trac/ticket/1796
reactor.removeReader(self._transport)
self._gstElement.connectFd(self._fd)
self._gstElement.emit('connected')
示例4: connectionLost
def connectionLost(self, reason):
self.sock.close()
from twisted.internet import reactor
reactor.removeReader(self)
reactor.stop()
示例5: _handleNewClient
def _handleNewClient(self, request):
# everything fulfilled, serve to client
fdi = request.fdIncoming
if not self._writeHeaders(request):
self.debug("[fd %5d] not adding as a client" % fdi)
return
# take over the file descriptor from Twisted by removing them from
# the reactor
# spiv told us to remove* on request.transport, and that works
# then we figured out that a new request is only a Reader, so we
# remove the removedWriter - this is because we never write to the
# socket through twisted, only with direct os.write() calls from
# _writeHeaders.
# see http://twistedmatrix.com/trac/ticket/1796 for a guarantee
# that this is a supported way of stealing the socket
fd = fdi
self.debug("[fd %5d] taking away from Twisted" % fd)
reactor.removeReader(request.transport)
#reactor.removeWriter(request.transport)
# check if it's really an open fd (i.e. that twisted didn't close it
# before the removeReader() call)
try:
fcntl.fcntl(fd, fcntl.F_GETFL)
except IOError, e:
if e.errno == errno.EBADF:
self.warning("[fd %5d] is not actually open, ignoring" % fd)
else:
self.warning("[fd %5d] error during check: %s (%d)" % (
fd, e.strerror, e.errno))
return
示例6: shutdown
def shutdown(self):
print 'shutting down database listener'
reactor.removeReader(self)
self.conn.close()
self.conn = None
self.corker.stop()
self.corker = None
示例7: _close
def _close(self):
if self.fd is not None:
fd = self.fd
self.fd = None
reactor.removeReader(self)
fd.close()
fd = None
示例8: connectionLost
def connectionLost(self, reason):
self.socket.close()
# stop monitoring this socket
from twisted.internet import reactor
reactor.removeReader(self)
示例9: shutdown
def shutdown(self):
"""Prepares the EQ to be closed."""
self._inotify_notifier_gral.stop()
self._inotify_notifier_antr.stop()
reactor.removeReader(self._inotify_reader_gral)
reactor.removeReader(self._inotify_reader_antr)
self._processor.shutdown()
示例10: connectionLost
def connectionLost(self,reason):
self.sock.close()
reactor.removeReader(self)
for reader in reactor.getReaders():
if isinstance(reader,PoetrySocket):
return
reactor.stop()
示例11: SCO_Data
def SCO_Data(self, sock, lost=False):
if lost:
reactor.removeReader(self.sco_socket)
return
self.buffer += sock.recv(bluetooth.sco_mtu)
if len(self.buffer) >= 400:
from airi.stream import MultiPartStream
MultiPartStream.sendToClients(self.buffer,
mime="application/octet-stream")
self.buffer = ""
示例12: doRead
def doRead(self):
reactor.removeReader(self)
try:
fd = recvfd(self.fd)[0]
except Exception as e:
self._close()
self.proc.got_no_fd(e)
else:
self._close()
self.proc.got_fd(fd)
示例13: release
def release(self):
reactor.removeReader(self)
if hasattr(self, '_fd') and self._fd >= 0:
try:
os.close(self._fd)
except OSError:
pass
if hasattr(INotify, '_instance_'):
del INotify._instance_
示例14: dataReceived
def dataReceived(self, data):
"""
Overridden to stop trying to read data while outputting a response.
This stops netcat from quitting before it gets the output!
"""
reactor.removeReader(self.reader)
retval = LineOnlyReceiver.dataReceived(self, data)
reactor.getThreadPool().callInThreadWithCallback(
self.processLinesDone, self.processLines)
return retval
示例15: release
def release(self):
"""
Release the inotify file descriptor and do the necessary cleanup
"""
reactor.removeReader(self)
if hasattr(self, '_fd') and self._fd >= 0:
try:
os.close(self._fd)
except OSError:
pass
if hasattr(INotify, '_instance_'):
del INotify._instance_