python类file_dispatcher()的实例源码

loadbalancerTCP.py 文件源码 项目:dmpt 作者: sistason 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, options={}):
        self.secret = options.get('secret','')
        self.port = options.get('port',11111)
        self.buffer = []
        self.loadbalancer_pool = []

        _tap = options.get('tap', True)
        _name = options.get('name', '')
        self.dev = TapDevice(tap=_tap, name=_name)

        asyncore.file_dispatcher.__init__(self, self.dev.getFD())

        self.dev.up()
        if options.get('tunnel_address', False):
            self.dev.ifconfig(address=options.get('tunnel_address'))

        logging.debug('Interface ready')
queueasyncthread.py 文件源码 项目:appfirewall 作者: danielrocher 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, callback, queue_number=0, debug=False):
        Thread.__init__(self)
        self.debug=debug
        self._stop = False
        self.nf_queue_started=False
        self.queue_number=queue_number
        self.q = nfqueue.queue()
        self.printDebug("Setting callback")
        self.q.set_callback(callback)
        self.printDebug("Open nfqueue number %s" % self.queue_number)
        try:
            self.q.fast_open(self.queue_number, AF_INET6)
            self.fd = self.q.get_fd()
            self.q.set_queue_maxlen(100000)
            asyncore.file_dispatcher.__init__(self, self.fd, None)
            self.q.set_mode(nfqueue.NFQNL_COPY_PACKET)
        except:
            self._stop = True
            print "Impossible to open NetFilter Queue {}".format(self.queue_number)
            return

        self.nf_queue_started=True
        self.printDebug("Queue is ready")
select_trigger.py 文件源码 项目:aquests 作者: hansroh 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__ (self, logger = None):
            r, w = os.pipe()
            self.trigger = w
            self.logger = logger
            asyncore.file_dispatcher.__init__ (self, r)
            self.lock = _thread.allocate_lock()
            self.thunks = []
pyinotify.py 文件源码 项目:ClassiPi 作者: mugroma3 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __init__(self, watch_manager, default_proc_fun=None, read_freq=0,
                 threshold=0, timeout=None, channel_map=None):
        """
        Initializes the async notifier. The only additional parameter is
        'channel_map' which is the optional asyncore private map. See
        Notifier class for the meaning of the others parameters.

        """
        Notifier.__init__(self, watch_manager, default_proc_fun, read_freq,
                          threshold, timeout)
        asyncore.file_dispatcher.__init__(self, self._fd, channel_map)
pyinotify.py 文件源码 项目:isar 作者: ilbers 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, watch_manager, default_proc_fun=None, read_freq=0,
                 threshold=0, timeout=None, channel_map=None):
        """
        Initializes the async notifier. The only additional parameter is
        'channel_map' which is the optional asyncore private map. See
        Notifier class for the meaning of the others parameters.

        """
        Notifier.__init__(self, watch_manager, default_proc_fun, read_freq,
                          threshold, timeout)
        asyncore.file_dispatcher.__init__(self, self._fd, channel_map)
network.py 文件源码 项目:heartbreaker 作者: lokori 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__(self, f):
        asyncore.file_dispatcher.__init__(self,f)
        self.buffer=""
test_asyncore.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_dispatcher(self):
        fd = os.open(TESTFN, os.O_RDONLY)
        data = []
        class FileDispatcher(asyncore.file_dispatcher):
            def handle_read(self):
                data.append(self.recv(29))
        s = FileDispatcher(fd)
        os.close(fd)
        asyncore.loop(timeout=0.01, use_poll=True, count=2)
        self.assertEqual(b"".join(data), self.d)
loadbalancerUDP.py 文件源码 项目:dmpt 作者: sistason 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def __init__(self, options={}):
        self.shutdown = False           # Loadbalancers shouldn't reconnect
        self.buffer = []
        self.loadbalancing_pool = []
        self.rr = 0                     # RoundRobin iterator counter
        self.weighted_rr_queue = []     # Weighted RoundRobin queue

        self.secret = options.get('secret','')
        self.port = options.get('port',11111)
        mode = options.get('mode','rr')
        if mode not in self.available_modes.keys():
            logging.error('Unknown Mode "{}"!'.format(mode))
        self.balancing_mode = self.available_modes.get(mode, 'rr')

        _tap = options.get('tap', True)
        _name = options.get('name', '')
        _mtu = 1496-28-200
        self.dev = TapDevice(tap=_tap, name=_name)
        self.dev.ifconfig(mtu=_mtu)

        asyncore.file_dispatcher.__init__(self, self.dev.getFD())

        self.dev.up()
        if options.get('tunnel_address', False):
            self.dev.ifconfig(address=options.get('tunnel_address'))

        logging.debug('Interface ready')
test_asyncore.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_dispatcher(self):
        fd = os.open(TESTFN, os.O_RDONLY)
        data = []
        class FileDispatcher(asyncore.file_dispatcher):
            def handle_read(self):
                data.append(self.recv(29))
        s = FileDispatcher(fd)
        os.close(fd)
        asyncore.loop(timeout=0.01, use_poll=True, count=2)
        self.assertEqual(b"".join(data), self.d)
test_asyncore.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_dispatcher(self):
        fd = os.open(TESTFN, os.O_RDONLY)
        data = []
        class FileDispatcher(asyncore.file_dispatcher):
            def handle_read(self):
                data.append(self.recv(29))
        s = FileDispatcher(fd)
        os.close(fd)
        asyncore.loop(timeout=0.01, use_poll=True, count=2)
        self.assertEqual(b"".join(data), self.d)
test_asyncore.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_dispatcher(self):
        fd = os.open(TESTFN, os.O_RDONLY)
        data = []
        class FileDispatcher(asyncore.file_dispatcher):
            def handle_read(self):
                data.append(self.recv(29))
        s = FileDispatcher(fd)
        os.close(fd)
        asyncore.loop(timeout=0.01, use_poll=True, count=2)
        self.assertEqual(b"".join(data), self.d)
test_asyncore.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_dispatcher(self):
        fd = os.open(TESTFN, os.O_RDONLY)
        data = []
        class FileDispatcher(asyncore.file_dispatcher):
            def handle_read(self):
                data.append(self.recv(29))
        s = FileDispatcher(fd)
        os.close(fd)
        asyncore.loop(timeout=0.01, use_poll=True, count=2)
        self.assertEqual(b"".join(data), self.d)
test_asyncore.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_dispatcher(self):
        fd = os.open(support.TESTFN, os.O_RDONLY)
        data = []
        class FileDispatcher(asyncore.file_dispatcher):
            def handle_read(self):
                data.append(self.recv(29))
        s = FileDispatcher(fd)
        os.close(fd)
        asyncore.loop(timeout=0.01, use_poll=True, count=2)
        self.assertEqual(b"".join(data), self.d)
test_asyncore.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_dispatcher(self):
        fd = os.open(TESTFN, os.O_RDONLY)
        data = []
        class FileDispatcher(asyncore.file_dispatcher):
            def handle_read(self):
                data.append(self.recv(29))
        s = FileDispatcher(fd)
        os.close(fd)
        asyncore.loop(timeout=0.01, use_poll=True, count=2)
        self.assertEqual(b"".join(data), self.d)
channels.py 文件源码 项目:RPKI-toolkit 作者: pavel-odintsov 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def init_file_dispatcher(self, fd):
    """
    Kludge to plug asyncore.file_dispatcher into asynchat.  Call from
    subclass's __init__() method, after calling
    PDUChannel.__init__(), and don't read this on a full stomach.
    """

    self.connected = True
    self._fileno = fd
    self.socket = asyncore.file_wrapper(fd)
    self.add_channel()
    flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0)
    flags = flags | os.O_NONBLOCK
    fcntl.fcntl(fd, fcntl.F_SETFL, flags)
channels.py 文件源码 项目:RPKI-toolkit 作者: pavel-odintsov 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def init_file_dispatcher(self, fd):
    """
    Kludge to plug asyncore.file_dispatcher into asynchat.  Call from
    subclass's __init__() method, after calling
    PDUChannel.__init__(), and don't read this on a full stomach.
    """

    self.connected = True
    self._fileno = fd
    self.socket = asyncore.file_wrapper(fd)
    self.add_channel()
    flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0)
    flags = flags | os.O_NONBLOCK
    fcntl.fcntl(fd, fcntl.F_SETFL, flags)
channels.py 文件源码 项目:RPKI-toolkit 作者: pavel-odintsov 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def init_file_dispatcher(self, fd):
    """
    Kludge to plug asyncore.file_dispatcher into asynchat.  Call from
    subclass's __init__() method, after calling
    PDUChannel.__init__(), and don't read this on a full stomach.
    """

    self.connected = True
    self._fileno = fd
    self.socket = asyncore.file_wrapper(fd)
    self.add_channel()
    flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0)
    flags = flags | os.O_NONBLOCK
    fcntl.fcntl(fd, fcntl.F_SETFL, flags)
channels.py 文件源码 项目:RPKI-toolkit 作者: pavel-odintsov 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def init_file_dispatcher(self, fd):
    """
    Kludge to plug asyncore.file_dispatcher into asynchat.  Call from
    subclass's __init__() method, after calling
    PDUChannel.__init__(), and don't read this on a full stomach.
    """

    self.connected = True
    self._fileno = fd
    self.socket = asyncore.file_wrapper(fd)
    self.add_channel()
    flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0)
    flags = flags | os.O_NONBLOCK
    fcntl.fcntl(fd, fcntl.F_SETFL, flags)
channels.py 文件源码 项目:RPKI-toolkit 作者: pavel-odintsov 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def init_file_dispatcher(self, fd):
    """
    Kludge to plug asyncore.file_dispatcher into asynchat.  Call from
    subclass's __init__() method, after calling
    PDUChannel.__init__(), and don't read this on a full stomach.
    """

    self.connected = True
    self._fileno = fd
    self.socket = asyncore.file_wrapper(fd)
    self.add_channel()
    flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0)
    flags = flags | os.O_NONBLOCK
    fcntl.fcntl(fd, fcntl.F_SETFL, flags)
channels.py 文件源码 项目:RPKI-toolkit 作者: pavel-odintsov 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def init_file_dispatcher(self, fd):
    """
    Kludge to plug asyncore.file_dispatcher into asynchat.  Call from
    subclass's __init__() method, after calling
    PDUChannel.__init__(), and don't read this on a full stomach.
    """

    self.connected = True
    self._fileno = fd
    self.socket = asyncore.file_wrapper(fd)
    self.add_channel()
    flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0)
    flags = flags | os.O_NONBLOCK
    fcntl.fcntl(fd, fcntl.F_SETFL, flags)
test_asyncore.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_dispatcher(self):
        fd = os.open(support.TESTFN, os.O_RDONLY)
        data = []
        class FileDispatcher(asyncore.file_dispatcher):
            def handle_read(self):
                data.append(self.recv(29))
        s = FileDispatcher(fd)
        os.close(fd)
        asyncore.loop(timeout=0.01, use_poll=True, count=2)
        self.assertEqual(b"".join(data), self.d)
pyinotify.py 文件源码 项目:hacker-scripts 作者: restran 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def __init__(self, watch_manager, default_proc_fun=None, read_freq=0,
                 threshold=0, timeout=None, channel_map=None):
        """
        Initializes the async notifier. The only additional parameter is
        'channel_map' which is the optional asyncore private map. See
        Notifier class for the meaning of the others parameters.

        """
        Notifier.__init__(self, watch_manager, default_proc_fun, read_freq,
                          threshold, timeout)
        asyncore.file_dispatcher.__init__(self, self._fd, channel_map)
thread_channel.py 文件源码 项目:ZServer 作者: zopefoundation 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, channel, function, *args):
        self.parent = channel
        self.function = function
        self.args = args
        self.pipe = rfd, wfd = os.pipe()
        asyncore.file_dispatcher.__init__(self, rfd)
select_trigger.py 文件源码 项目:ZServer 作者: zopefoundation 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self):
            r, w = os.pipe()
            self.trigger = w
            asyncore.file_dispatcher.__init__(self, r)
            self.lock = thread.allocate_lock()
            self.thunks = []
commons.py 文件源码 项目:dmarc-tester 作者: usnistgov 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def handle_close(self):
    self.close()

#end class PipeReader(asyncore.file_dispatcher).
commons.py 文件源码 项目:dmarc-tester 作者: usnistgov 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def handle_close(self):
    self.close()

#end class PipeReader(asyncore.file_dispatcher).


问题


面经


文章

微信
公众号

扫码关注公众号