• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python log.msg函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中reqs.twisted.python.log.msg函数的典型用法代码示例。如果您正苦于以下问题:Python msg函数的具体用法?Python msg怎么用?Python msg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了msg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: handleAccept

    def handleAccept(self, rc, evt):
        if self.disconnecting or self.disconnected:
            return False

        # possible errors:
        # (WSAEMFILE, WSAENOBUFS, WSAENFILE, WSAENOMEM, WSAECONNABORTED)
        if rc:
            log.msg("Could not accept new connection -- %s (%s)" %
                    (errno.errorcode.get(rc, 'unknown error'), rc))
            return False
        else:
            evt.newskt.setsockopt(socket.SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT,
                                  struct.pack('I', self.socket.fileno()))
            family, lAddr, rAddr = _iocp.get_accept_addrs(evt.newskt.fileno(),
                                                          evt.buff)
            assert family == self.addressFamily

            protocol = self.factory.buildProtocol(
                address._ServerFactoryIPv4Address('TCP', rAddr[0], rAddr[1]))
            if protocol is None:
                evt.newskt.close()
            else:
                s = self.sessionno
                self.sessionno = s+1
                transport = Server(evt.newskt, protocol,
                        address.IPv4Address('TCP', rAddr[0], rAddr[1], 'INET'),
                        address.IPv4Address('TCP', lAddr[0], lAddr[1], 'INET'),
                        s, self.reactor)
                protocol.makeConnection(transport)
            return True
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:30,代码来源:tcp.py


示例2: connectionLost

    def connectionLost(self, reason):
        """
        Cleans up the socket.
        """
        log.msg('(Port %s Closed)' % self._realPortNumber)
        self._realPortNumber = None
        d = None
        if hasattr(self, "deferred"):
            d = self.deferred
            del self.deferred

        self.disconnected = True
        self.reactor.removeActiveHandle(self)
        self.connected = False
        self._closeSocket()
        del self.socket
        del self.getFileHandle

        try:
            self.factory.doStop()
        except:
            self.disconnecting = False
            if d is not None:
                d.errback(failure.Failure())
            else:
                raise
        else:
            self.disconnecting = False
            if d is not None:
                d.callback(None)
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:30,代码来源:tcp.py


示例3: doWaitForMultipleEvents

    def doWaitForMultipleEvents(self, timeout):
        log.msg(channel='system', event='iteration', reactor=self)
        if timeout is None:
            #timeout = INFINITE
            timeout = 100
        else:
            timeout = int(timeout * 1000)

        if not (self._events or self._writes):
            # sleep so we don't suck up CPU time
            time.sleep(timeout / 1000.0)
            return

        canDoMoreWrites = 0
        for fd in self._writes.keys():
            if log.callWithLogger(fd, self._runWrite, fd):
                canDoMoreWrites = 1

        if canDoMoreWrites:
            timeout = 0

        handles = self._events.keys() or [self.dummyEvent]
        val = MsgWaitForMultipleObjects(handles, 0, timeout, QS_ALLINPUT | QS_ALLEVENTS)
        if val == WAIT_TIMEOUT:
            return
        elif val == WAIT_OBJECT_0 + len(handles):
            exit = win32gui.PumpWaitingMessages()
            if exit:
                self.callLater(0, self.stop)
                return
        elif val >= WAIT_OBJECT_0 and val < WAIT_OBJECT_0 + len(handles):
            fd, action = self._events[handles[val - WAIT_OBJECT_0]]
            log.callWithLogger(fd, self._runAction, action, fd)
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:33,代码来源:win32eventreactor.py


示例4: _readAndWrite

    def _readAndWrite(self, source, condition):
        # note: gtk-1.2's gtk_input_add presents an API in terms of gdk
        # constants like INPUT_READ and INPUT_WRITE. Internally, it will add
        # POLL_HUP and POLL_ERR to the poll() events, but if they happen it
        # will turn them back into INPUT_READ and INPUT_WRITE. gdkevents.c
        # maps IN/HUP/ERR to INPUT_READ, and OUT/ERR to INPUT_WRITE. This
        # means there is no immediate way to detect a disconnected socket.

        # The g_io_add_watch() API is more suited to this task. I don't think
        # pygtk exposes it, though.
        why = None
        didRead = None
        try:
            if condition & gtk.GDK.INPUT_READ:
                why = source.doRead()
                didRead = source.doRead
            if not why and condition & gtk.GDK.INPUT_WRITE:
                # if doRead caused connectionLost, don't call doWrite
                # if doRead is doWrite, don't call it again.
                if not source.disconnected and source.doWrite != didRead:
                    why = source.doWrite()
                    didRead = source.doWrite # if failed it was in write
        except:
            why = sys.exc_info()[1]
            log.msg('Error In %s' % source)
            log.deferr()

        if why:
            self._disconnectSelectable(source, why, didRead == source.doRead)
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:29,代码来源:gtkreactor.py


示例5: unpickleMethod

def unpickleMethod(im_name,
                    im_self,
                    im_class):
    'support function for copy_reg to unpickle method refs'
    try:
        unbound = getattr(im_class,im_name)
        if im_self is None:
            return unbound
        bound=instancemethod(unbound.im_func,
                                 im_self,
                                 im_class)
        return bound
    except AttributeError:
        log.msg("Method",im_name,"not on class",im_class)
        assert im_self is not None,"No recourse: no instance to guess from."
        # Attempt a common fix before bailing -- if classes have
        # changed around since we pickled this method, we may still be
        # able to get it by looking on the instance's current class.
        unbound = getattr(im_self.__class__,im_name)
        log.msg("Attempting fixup with",unbound)
        if im_self is None:
            return unbound
        bound=instancemethod(unbound.im_func,
                                 im_self,
                                 im_self.__class__)
        return bound
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:26,代码来源:styles.py


示例6: unpickleModule

def unpickleModule(name):
    'support function for copy_reg to unpickle module refs'
    if oldModules.has_key(name):
        log.msg("Module has moved: %s" % name)
        name = oldModules[name]
        log.msg(name)
    return __import__(name,{},{},'x')
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:7,代码来源:styles.py


示例7: startListening

    def startListening(self):
        """Create and bind my socket, and begin listening on it.

        This is called on unserialization, and must be called after creating a
        server to begin listening on the specified port.
        """
        log.msg("%s starting on %r" % (self.factory.__class__, repr(self.port)))
        if self.wantPID:
            self.lockFile = lockfile.FilesystemLock(self.port + ".lock")
            if not self.lockFile.lock():
                raise CannotListenError, (None, self.port, "Cannot acquire lock")
            else:
                if not self.lockFile.clean:
                    try:
                        # This is a best-attempt at cleaning up
                        # left-over unix sockets on the filesystem.
                        # If it fails, there's not much else we can
                        # do.  The bind() below will fail with an
                        # exception that actually propegates.
                        if stat.S_ISSOCK(os.stat(self.port).st_mode):
                            os.remove(self.port)
                    except:
                        pass

        self.factory.doStart()
        try:
            skt = self.createInternetSocket()
            skt.bind(self.port)
        except socket.error, le:
            raise CannotListenError, (None, self.port, le)
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:30,代码来源:unix.py


示例8: __getstate__

 def __getstate__(self):
     log.msg( "WARNING: serializing ephemeral %s" % self )
     import gc
     if getattr(gc, 'get_referrers', None):
         for r in gc.get_referrers(self):
             log.msg( " referred to by %s" % (r,))
     return None
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:7,代码来源:styles.py


示例9: _doReadOrWrite

    def _doReadOrWrite(self, source, condition, faildict={
        error.ConnectionDone: failure.Failure(error.ConnectionDone()),
        error.ConnectionLost: failure.Failure(error.ConnectionLost()),
        }):
        why = None
        inRead = False
        if condition & POLL_DISCONNECTED and not (condition & gobject.IO_IN):
            if source in self._reads:
                why = main.CONNECTION_DONE
                inRead = True
            else:
                why = main.CONNECTION_LOST
        else:
            try:
                if condition & gobject.IO_IN:
                    why = source.doRead()
                    inRead = True
                if not why and condition & gobject.IO_OUT:
                    # if doRead caused connectionLost, don't call doWrite
                    # if doRead is doWrite, don't call it again.
                    if not source.disconnected:
                        why = source.doWrite()
            except:
                why = sys.exc_info()[1]
                log.msg('Error In %s' % source)
                log.deferr()

        if why:
            self._disconnectSelectable(source, why, inRead)
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:29,代码来源:gtk2reactor.py


示例10: throttleReads

 def throttleReads(self):
     """
     Throttle reads on all protocols.
     """
     log.msg("Throttling reads on %s" % self)
     for p in self.protocols.keys():
         p.throttleReads()
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:7,代码来源:policies.py


示例11: throttleWrites

 def throttleWrites(self):
     """
     Throttle writes on all protocols.
     """
     log.msg("Throttling writes on %s" % self)
     for p in self.protocols.keys():
         p.throttleWrites()
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:7,代码来源:policies.py


示例12: reapProcess

    def reapProcess(self):
        """
        Try to reap a process (without blocking) via waitpid.

        This is called when sigchild is caught or a Process object loses its
        "connection" (stdout is closed) This ought to result in reaping all
        zombie processes, since it will be called twice as often as it needs
        to be.

        (Unfortunately, this is a slightly experimental approach, since
        UNIX has no way to be really sure that your process is going to
        go away w/o blocking.  I don't want to block.)
        """
        try:
            try:
                pid, status = os.waitpid(self.pid, os.WNOHANG)
            except OSError, e:
                if e.errno == errno.ECHILD:
                    # no child process
                    pid = None
                else:
                    raise
        except:
            log.msg('Failed to reap %d:' % self.pid)
            log.err()
            pid = None
        if pid:
            self.processEnded(status)
            unregisterReapProcessHandler(pid, self)
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:29,代码来源:process.py


示例13: jelly

 def jelly(self, obj):
     try:
         ao = self.jellyToAO(obj)
         return ao
     except:
         log.msg("Error jellying object! Stacktrace follows::")
         log.msg(string.join(self.stack, '\n'))
         raise
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:8,代码来源:aot.py


示例14: _bindSocket

 def _bindSocket(self):
     log.msg("%s starting on %s"%(self.protocol.__class__, repr(self.port)))
     try:
         skt = self.createInternetSocket() # XXX: haha misnamed method
         if self.port:
             skt.bind(self.port)
     except socket.error, le:
         raise error.CannotListenError, (None, self.port, le)
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:8,代码来源:unix.py


示例15: processExited

 def processExited(self, reason):
     msg('processExited(%r)' % (reason,))
     # Protect the Deferred from the failure so that it follows
     # the callback chain.  This doesn't use the errback chain
     # because it wants to make sure reason is a Failure.  An
     # Exception would also make an errback-based test pass, and
     # that would be wrong.
     exited.callback([reason])
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:8,代码来源:test_process.py


示例16: lineReceived

 def lineReceived(self, line):
     if not self.queries:
         log.msg("Unexpected server response: %r" % (line,))
     else:
         d, _, _ = self.queries.pop(0)
         self.parseResponse(d, line)
         if self.queries:
             self.sendLine('%d, %d' % (self.queries[0][1], self.queries[0][2]))
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:8,代码来源:ident.py


示例17: unthrottleWrites

 def unthrottleWrites(self):
     """
     Stop throttling writes on all protocols.
     """
     self.unthrottleWritesID = None
     log.msg("Stopped throttling writes on %s" % self)
     for p in self.protocols.keys():
         p.unthrottleWrites()
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:8,代码来源:policies.py


示例18: buildProtocol

 def buildProtocol(self):
     if self.ircui:
         log.msg("already logged in")
         return None
     i = IRCUserInterface()
     i.factory = self
     self.ircui = i
     return i
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:8,代码来源:proxyui.py


示例19: proceed

 def proceed(protos, port):
     log.msg('PROCEEDING WITH THE TESTATHRON')
     self.assert_(protos[0])
     self.assert_(protos[1])
     protos = protos[0][1], protos[1][1]
     protos[0].transport.write(
             'x' * (2 * protos[0].transport.readBufferSize) +
             'y' * (2 * protos[0].transport.readBufferSize))
     return sf.stop_d.addCallback(cleanup, protos, port)
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:9,代码来源:test_iocp.py


示例20: __getattr__

 def __getattr__(self, key):
     try:
         return getattr(self.mainMod, key)
     except AttributeError:
         if self.initRun:
             raise
         else:
             log.msg("Warning!  Loading from __main__: %s" % key)
             return styles.Ephemeral()
开发者ID:Hetal728,项目名称:SMP-ClassiCube,代码行数:9,代码来源:sob.py



注:本文中的reqs.twisted.python.log.msg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python requesocks.session函数代码示例发布时间:2022-05-26
下一篇:
Python reactor.callLater函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap