本文整理汇总了Python中twisted.internet.reactor.removeReader函数的典型用法代码示例。如果您正苦于以下问题:Python removeReader函数的具体用法?Python removeReader怎么用?Python removeReader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了removeReader函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:29,代码来源:inetd.py
示例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()]
开发者ID:manuelnaranjo,项目名称:AIRi,代码行数:7,代码来源:bluez.py
示例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')
开发者ID:ApsOps,项目名称:flumotion-orig,代码行数:7,代码来源:protocol.py
示例4: connectionLost
def connectionLost(self, reason):
self.sock.close()
from twisted.internet import reactor
reactor.removeReader(self)
reactor.stop()
开发者ID:elenaoat,项目名称:tests,代码行数:7,代码来源:own_twisted_client.py
示例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
开发者ID:ApsOps,项目名称:flumotion-orig,代码行数:33,代码来源:mfdsresources.py
示例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
开发者ID:ponycloud,项目名称:sparkle,代码行数:7,代码来源:listener.py
示例7: _close
def _close(self):
if self.fd is not None:
fd = self.fd
self.fd = None
reactor.removeReader(self)
fd.close()
fd = None
开发者ID:smurfix,项目名称:twistfuse,代码行数:7,代码来源:handler.py
示例8: connectionLost
def connectionLost(self, reason):
self.socket.close()
# stop monitoring this socket
from twisted.internet import reactor
reactor.removeReader(self)
开发者ID:aircable,项目名称:AIRi,代码行数:7,代码来源:airidroid.py
示例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()
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:7,代码来源:filesystem_notifications.py
示例10: connectionLost
def connectionLost(self,reason):
self.sock.close()
reactor.removeReader(self)
for reader in reactor.getReaders():
if isinstance(reader,PoetrySocket):
return
reactor.stop()
开发者ID:chen19901225,项目名称:SimplePyCode,代码行数:9,代码来源:get_poetry.py
示例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 = ""
开发者ID:manuelnaranjo,项目名称:AIRi,代码行数:10,代码来源:airicamera.py
示例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)
开发者ID:smurfix,项目名称:twistfuse,代码行数:10,代码来源:handler.py
示例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_
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:10,代码来源:inotify.py
示例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
开发者ID:RIPE-NCC,项目名称:ripestat-text,代码行数:11,代码来源:server.py
示例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_
开发者ID:BlackHole,项目名称:coherence,代码行数:13,代码来源:inotify.py
示例16: connectionLost
def connectionLost(self, reason):
self.sock.close()
# stop monitoring this socket
from twisted.internet import reactor
reactor.removeReader(self)
# see if there are any poetry sockets left
for reader in reactor.getReaders():
if isinstance(reader, PoetrySocket):
return
reactor.stop() # no more poetry
开发者ID:bynoting,项目名称:python,代码行数:13,代码来源:get-poetry-broken.py
示例17: socket_remove
def socket_remove(id, condition=IO_READ):
"""
Removes the IRead/WriteDescriptor object with this socket from
the Twisted reactor.
"""
global __sockobjs
sockobj = __sockobjs[condition].get(id)
if sockobj:
if condition == IO_READ:
reactor.removeReader(sockobj)
elif condition == IO_WRITE:
reactor.removeWriter(sockobj)
del __sockobjs[condition][id]
开发者ID:kanyanat3,项目名称:ka-lite,代码行数:14,代码来源:nf_twisted.py
示例18: forkPassingFD
def forkPassingFD(exe, args, env, user, group, fdesc):
"""Run exe as a child process, passing fdesc as fd 0.
This will also make sure that fdesc is removed from the parent's reactor.
"""
# This is half-cannibalised from twisted.internet.process.Process
pid = os.fork()
if pid == 0: # Child
try:
# Close stdin/stdout (we keep stderr from the parent to report
# errors with)
for fd in range(2):
os.close(fd)
# Make the socket be fd 0
# (and fd 1, although I'm not sure if that matters)
os.dup(fdesc.fileno())
os.dup(fdesc.fileno())
# Close unused file descriptors
for fd in range(3, 256):
try: os.close(fd)
except: pass
# Set uid/gid
os.setgid(group)
os.setuid(user)
# Start the new process
os.execvpe(exe, args, env)
except:
# If anything goes wrong, just die.
stderr = os.fdopen(2, 'w')
stderr.write('Unable to spawn child:\n')
traceback.print_exc(file=stderr)
# Close the socket so the client doesn't think it's still
# connected to a server
try:
s = socket.fromfd(0, socket.AF_INET, socket.SOCK_STREAM)
s.shutdown(2)
except:
pass
os._exit(1)
else: # Parent
reactor.removeReader(fdesc)
reactor.removeWriter(fdesc)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:47,代码来源:inetd.py
示例19: test_getReaders
def test_getReaders(self):
"""
Check that L{interfaces.IReactorFDSet.getReaders} reflects the actions
made with L{interfaces.IReactorFDSet.addReader} and
L{interfaces.IReactorFDSet.removeReader}.
"""
s = socket.socket()
self.addCleanup(s.close)
c = Connection(s, protocol.Protocol())
self.assertNotIn(c, reactor.getReaders())
reactor.addReader(c)
self.assertIn(c, reactor.getReaders())
reactor.removeReader(c)
self.assertNotIn(c, reactor.getReaders())
开发者ID:hortonworkstest,项目名称:hortonworks-sandbox,代码行数:17,代码来源:test_internet.py
示例20: set_mode
def set_mode(self, mode_name, refresh=False):
log.debug('Setting console mode: %s', mode_name)
mode = self.modes.get(mode_name, None)
if mode is None:
log.error('Non-existent mode requested: %s', mode_name)
return
self.stdscr.erase()
if self.active_mode:
self.active_mode.pause()
d = component.pause([self.active_mode.mode_name])
def on_mode_paused(result, mode, *args):
from deluge.ui.console.widgets.popup import PopupsHandler
if isinstance(mode, PopupsHandler):
if mode.popup is not None:
# If popups are not removed, they are still referenced in the memory
# which can cause issues as the popup's screen will not be destroyed.
# This can lead to the popup border being visible for short periods
# while the current modes' screen is repainted.
log.error('Mode "%s" still has popups available after being paused.'
' Ensure all popups are removed on pause!', mode.popup.title)
d.addCallback(on_mode_paused, self.active_mode)
reactor.removeReader(self.active_mode)
self.active_mode = mode
self.statusbars.screen = self.active_mode
# The Screen object is designed to run as a twisted reader so that it
# can use twisted's select poll for non-blocking user input.
reactor.addReader(self.active_mode)
self.stdscr.clear()
if self.active_mode._component_state == 'Stopped':
component.start([self.active_mode.mode_name])
else:
component.resume([self.active_mode.mode_name])
mode.resume()
if refresh:
mode.refresh()
return mode
开发者ID:deluge-torrent,项目名称:deluge,代码行数:42,代码来源:main.py
注:本文中的twisted.internet.reactor.removeReader函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论