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

Python asyncore_25.compact_traceback函数代码示例

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

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



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

示例1: found_terminator

    def found_terminator (self):
        self.buffer, data = [], ''.join(self.buffer)

        if self.pstate is self.STATE_LENGTH:
            packet_length = int (data, 16)
            self.set_terminator (packet_length)
            self.pstate = self.STATE_PACKET
        else:
            self.set_terminator (8)
            self.pstate = self.STATE_LENGTH
            (path, params) = marshal.loads (data)
            o = self.root

            e = None

            try:
                for p in path:
                    o = getattr (o, p)
                result = o(*params)
            except:
                e = repr (asyncore.compact_traceback())
                result = None

            rb = marshal.dumps ((e,result))
            self.push (('%08x' % len(rb)) + rb)
开发者ID:lmcdonough,项目名称:supervisor,代码行数:25,代码来源:rpc_server.py


示例2: _spawn_as_child

 def _spawn_as_child(self, filename, argv):
     options = self.config.options
     try:
         # prevent child from receiving signals sent to the
         # parent by calling os.setpgrp to create a new process
         # group for the child; this prevents, for instance,
         # the case of child processes being sent a SIGINT when
         # running supervisor in foreground mode and Ctrl-C in
         # the terminal window running supervisord is pressed.
         # Presumably it also prevents HUP, etc received by
         # supervisord from being sent to children.
         options.setpgrp()
         self._prepare_child_fds()
         # sending to fd 2 will put this output in the stderr log
         msg = self.set_uid()
         if msg:
             uid = self.config.uid
             s = 'supervisor: error trying to setuid to %s ' % uid
             options.write(2, s)
             options.write(2, "(%s)\n" % msg)
         env = os.environ.copy()
         env['SUPERVISOR_ENABLED'] = '1'
         serverurl = self.config.serverurl
         if serverurl is None: # unset
             serverurl = self.config.options.serverurl # might still be None
         if serverurl:
             env['SUPERVISOR_SERVER_URL'] = serverurl
         env['SUPERVISOR_PROCESS_NAME'] = self.config.name
         if self.group:
             env['SUPERVISOR_GROUP_NAME'] = self.group.config.name
         if self.config.environment is not None:
             env.update(self.config.environment)
         cwd = self.config.directory
         try:
             if cwd is not None:
                 options.chdir(cwd)
         except OSError:
             why = sys.exc_info()[1]
             code = errno.errorcode.get(why.args[0], why.args[0])
             msg = "couldn't chdir to %s: %s\n" % (cwd, code)
             options.write(2, msg)
         else:
             try:
                 if self.config.umask is not None:
                     options.setumask(self.config.umask)
                 options.execve(filename, argv, env)
             except OSError:
                 why = sys.exc_info()[1]
                 code = errno.errorcode.get(why.args[0], why.args[0])
                 msg = "couldn't exec %s: %s\n" % (argv[0], code)
                 options.write(2, msg)
             except:
                 (file, fun, line), t,v,tbinfo = asyncore.compact_traceback()
                 error = '%s, %s: file: %s line: %s' % (t, v, file, line)
                 options.write(2, "couldn't exec %s: %s\n" % (filename,
                                                              error))
     finally:
         options._exit(127)
开发者ID:lmcdonough,项目名称:supervisor,代码行数:58,代码来源:process.py


示例3: found_terminator

    def found_terminator (self):

        line = self.in_buffer

        if not len(line):
            return

        sp = line.find(' ')
        if sp != -1:
            line = [line[:sp], line[sp+1:]]
        else:
            line = [line]

        command = line[0].lower()
        # watch especially for 'urgent' abort commands.
        if command.find('abor') != -1:
            # strip off telnet sync chars and the like...
            while command and command[0] not in letters:
                command = command[1:]

        fun_name = 'cmd_%s' % command
        if command != 'pass':
            self.log ('<== %s' % repr(self.in_buffer)[1:-1])
        else:
            self.log ('<== %s' % line[0]+' <password>')
        self.in_buffer = ''
        if not hasattr (self, fun_name):
            self.command_not_understood (line[0])
            return
        if hasattr(self,'_rnfr_src') and fun_name!='cmd_rnto':
            del self._rnfr_src
            self.respond ('503 RNTO Command expected!')
            return

        fun = getattr (self, fun_name)
        if (not self.authorized) and (command not in ('user', 'pass', 'help', 'quit')):
            self.respond ('530 Please log in with USER and PASS')
        elif not self.check_command_authorization (command):
            self.command_not_authorized (command)
        else:
            try:
                fun(*(line,))
            except:
                self.server.total_exceptions.increment()
                (file, fun, line), t,v, tbinfo = asyncore.compact_traceback()
                if self.client_dc:
                    try:
                        self.client_dc.close()
                    except:
                        pass
                self.respond (
                        '451 Server Error: %s, %s: file: %s line: %s' % (
                                t,v,file,line,
                                )
                        )
开发者ID:GulsahKose,项目名称:supervisor,代码行数:55,代码来源:ftp_server.py


示例4: handle_error

    def handle_error(self):
        nil, t, v, tbinfo = compact_traceback()

        self.process.config.options.logger.critical(
            'uncaptured python exception, closing channel %s (%s:%s %s)' % (
                repr(self),
                t,
                v,
                tbinfo
                )
            )
        self.close()
开发者ID:WLPhoenix,项目名称:supervisor-py3k,代码行数:12,代码来源:dispatchers.py


示例5: reap

 def reap (self):          # find DNS requests that have timed out
     now = int(time.time())
     if now - self.last_reap_time > 180:        # reap every 3 minutes
         self.last_reap_time = now              # update before we forget
         for k,(host,unpack,callback,when) in list(self.request_map.items()):
             if now - when > 180:               # over 3 minutes old
                 del self.request_map[k]
                 try:                           # same code as in handle_read
                     callback (host, 0, None)   # timeout val is (0,None)
                 except:
                     file_fun_line, t, v, tbinfo = asyncore.compact_traceback()
                     self.log_info('%s %s %s' % (t,v,tbinfo), 'error')
开发者ID:lmcdonough,项目名称:supervisor,代码行数:12,代码来源:resolver.py


示例6: onecmd

 def onecmd(self, line):
     """ Override the onecmd method to:
       - catch and print all exceptions
       - allow for composite commands in interactive mode (foo; bar)
       - call 'do_foo' on plugins rather than ourself
     """
     origline = line
     lines = line.split(';') # don't filter(None, line.split), as we pop
     line = lines.pop(0)
     # stuffing the remainder into cmdqueue will cause cmdloop to
     # call us again for each command.
     self.cmdqueue.extend(lines)
     cmd, arg, line = self.parseline(line)
     if not line:
         return self.emptyline()
     if cmd is None:
         return self.default(line)
     self._complete_info = None
     self.lastcmd = line
     if cmd == '':
         return self.default(line)
     else:
         do_func = self._get_do_func(cmd)
         if do_func is None:
             return self.default(line)
         try:
             try:
                 return do_func(arg)
             except xmlrpclib.ProtocolError as e:
                 if e.errcode == 401:
                     if self.options.interactive:
                         self.output('Server requires authentication')
                         username = raw_input('Username:')
                         password = getpass.getpass(prompt='Password:')
                         self.output('')
                         self.options.username = username
                         self.options.password = password
                         return self.onecmd(origline)
                     else:
                         self.options.usage('Server requires authentication')
                 else:
                     raise
             do_func(arg)
         except SystemExit:
             raise
         except Exception:
             (file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
             error = 'error: %s, %s: file: %s line: %s' % (t, v, file, line)
             self.output(error)
             if not self.options.interactive:
                 sys.exit(2)
开发者ID:pataquets,项目名称:supervisor,代码行数:51,代码来源:supervisorctl.py


示例7: handle_read

 def handle_read (self):
     reply, whence = self.socket.recvfrom (512)
     # for security reasons we may want to double-check
     # that <whence> is the server we sent the request to.
     id = (ord(reply[0])<<8) + ord(reply[1])
     if id in self.request_map:
         host, unpack, callback, when = self.request_map[id]
         del self.request_map[id]
         ttl, answer = unpack (reply)
         try:
             callback (host, ttl, answer)
         except:
             file_fun_line, t, v, tbinfo = asyncore.compact_traceback()
             self.log_info('%s %s %s' % ( t,v,tbinfo), 'error')
开发者ID:lmcdonough,项目名称:supervisor,代码行数:14,代码来源:resolver.py


示例8: handle_read

 def handle_read (self):
     try:
         self.recv(8192)
     except socket.error:
         return
     self.lock.acquire()
     try:
         for thunk in self.thunks:
             try:
                 thunk()
             except:
                 nil, t, v, tbinfo = asyncore.compact_traceback()
                 print('exception in trigger thunk: (%s:%s %s)' % (t, v, tbinfo))
         self.thunks = []
     finally:
         self.lock.release()
开发者ID:lmcdonough,项目名称:supervisor,代码行数:16,代码来源:select_trigger.py


示例9: found_terminator

    def found_terminator (self):
        """ We only override this to use 'deferring_http_request' class
        instead of the normal http_request class; it sucks to need to override
        this """
        if self.current_request:
            self.current_request.found_terminator()
        else:
            header = self.in_buffer
            self.in_buffer = ''
            lines = header.split('\r\n')

            # --------------------------------------------------
            # crack the request header
            # --------------------------------------------------

            while lines and not lines[0]:
                # as per the suggestion of http-1.1 section 4.1, (and
                # Eric Parker <[email protected]>), ignore a leading
                # blank lines (buggy browsers tack it onto the end of
                # POST requests)
                lines = lines[1:]

            if not lines:
                self.close_when_done()
                return

            request = lines[0]

            command, uri, version = http_server.crack_request (request)
            header = http_server.join_headers (lines[1:])

            # unquote path if necessary (thanks to Skip Montanaro for pointing
            # out that we must unquote in piecemeal fashion).
            rpath, rquery = http_server.splitquery(uri)
            if '%' in rpath:
                if rquery:
                    uri = http_server.unquote (rpath) + '?' + rquery
                else:
                    uri = http_server.unquote (rpath)

            r = deferring_http_request (self, request, command, uri, version,
                                         header)
            self.request_counter.increment()
            self.server.total_requests.increment()

            if command is None:
                self.log_info ('Bad HTTP request: %s' % repr(request), 'error')
                r.error (400)
                return

            # --------------------------------------------------
            # handler selection and dispatch
            # --------------------------------------------------
            for h in self.server.handlers:
                if h.match (r):
                    try:
                        self.current_request = r
                        # This isn't used anywhere.
                        # r.handler = h # CYCLE
                        h.handle_request (r)
                    except:
                        self.server.exceptions.increment()
                        (file, fun, line), t, v, tbinfo = \
                               asyncore.compact_traceback()
                        self.server.log_info(
                            'Server Error: %s, %s: file: %s line: %s' %
                            (t,v,file,line),
                            'error')
                        try:
                            r.error (500)
                        except:
                            pass
                    return

            # no handlers, so complain
            r.error (404)
开发者ID:wowgeeker,项目名称:supervisor,代码行数:76,代码来源:http.py


示例10: stop

                    options.chdir(cwd)
            except OSError, why:
                code = errno.errorcode.get(why[0], why[0])
                msg = "couldn't chdir to %s: %s\n" % (cwd, code)
                options.write(2, msg)
            else:
                try:
                    if self.config.umask is not None:
                        options.setumask(self.config.umask)
                    options.execve(filename, argv, env)
                except OSError, why:
                    code = errno.errorcode.get(why[0], why[0])
                    msg = "couldn't exec %s: %s\n" % (argv[0], code)
                    options.write(2, msg)
                except:
                    (file, fun, line), t,v,tbinfo = asyncore.compact_traceback()
                    error = '%s, %s: file: %s line: %s' % (t, v, file, line)
                    options.write(2, "couldn't exec %s: %s\n" % (filename,
                                                                 error))
        finally:
            options._exit(127)

    def stop(self):
        """ Administrative stop """
        self.drain()
        self.administrative_stop = 1
        return self.kill(self.config.stopsignal)

    def give_up(self):
        self.delay = 0
        self.backoff = 0
开发者ID:JeremyGrosser,项目名称:supervisor,代码行数:31,代码来源:process.py


示例11: _spawn_as_child

    def _spawn_as_child(self, filename, argv):
        options = self.config.options
        try:
            # prevent child from receiving signals sent to the
            # parent by calling os.setpgrp to create a new process
            # group for the child; this prevents, for instance,
            # the case of child processes being sent a SIGINT when
            # running supervisor in foreground mode and Ctrl-C in
            # the terminal window running supervisord is pressed.
            # Presumably it also prevents HUP, etc received by
            # supervisord from being sent to children.
            options.setpgrp()

            self._prepare_child_fds()
            # sending to fd 2 will put this output in the stderr log

            # set user
            setuid_msg = self.set_uid()
            if setuid_msg:
                uid = self.config.uid
                msg = "couldn't setuid to %s: %s\n" % (uid, setuid_msg)
                options.write(2, "supervisor: " + msg)
                return # finally clause will exit the child process

            # set environment
            env = os.environ.copy()
            env['SUPERVISOR_ENABLED'] = '1'
            serverurl = self.config.serverurl
            if serverurl is None: # unset
                serverurl = self.config.options.serverurl # might still be None
            if serverurl:
                env['SUPERVISOR_SERVER_URL'] = serverurl
            env['SUPERVISOR_PROCESS_NAME'] = self.config.name
            if self.group:
                env['SUPERVISOR_GROUP_NAME'] = self.group.config.name
            if self.config.environment is not None:
                env.update(self.config.environment)
            # change directory
            cwd = self.config.directory
            try:
                if cwd is not None:
                    options.chdir(cwd)
            except OSError as why:
                code = errno.errorcode.get(why.args[0], why.args[0])
                msg = "couldn't chdir to %s: %s\n" % (cwd, code)
                options.write(2, "supervisor: " + msg)
                return # finally clause will exit the child process

            # set umask, then execve
            try:
                if self.config.umask is not None:
                    options.setumask(self.config.umask)
                options.execve(filename, argv, env)
            except OSError as why:
                code = errno.errorcode.get(why.args[0], why.args[0])
                msg = "couldn't exec %s: %s\n" % (argv[0], code)
                options.write(2, "supervisor: " + msg)
            except:
                (file, fun, line), t,v,tbinfo = asyncore.compact_traceback()
                error = '%s, %s: file: %s line: %s' % (t, v, file, line)
                msg = "couldn't exec %s: %s\n" % (filename, error)
                options.write(2, "supervisor: " + msg)

            # this point should only be reached if execve failed.
            # the finally clause will exit the child process.

        finally:
            options.write(2, "supervisor: child process was not spawned\n")
            options._exit(127) # exit process with code for spawn failure
开发者ID:gchiam,项目名称:supervisor,代码行数:69,代码来源:process.py


示例12: found_terminator

 def found_terminator (self):
     line = self.clean_line (self.data)
     self.data = ''
     self.line_counter.increment()
     # check for special case inputs...
     if not line and not self.multi_line:
         self.prompt()
         return
     if line in ['\004', 'exit']:
         self.push ('BCNU\r\n')
         self.close_when_done()
         return
     oldout = sys.stdout
     olderr = sys.stderr
     try:
         p = output_producer(self, olderr)
         sys.stdout = p
         sys.stderr = p
         try:
             # this is, of course, a blocking operation.
             # if you wanted to thread this, you would have
             # to synchronize, etc... and treat the output
             # like a pipe.  Not Fun.
             #
             # try eval first.  If that fails, try exec.  If that fails,
             # hurl.
             try:
                 if self.multi_line:
                     # oh, this is horrible...
                     raise SyntaxError
                 co = compile (line, repr(self), 'eval')
                 result = eval (co, self.local_env)
                 method = 'eval'
                 if result is not None:
                     print(repr(result))
                 self.local_env['_'] = result
             except SyntaxError:
                 try:
                     if self.multi_line:
                         if line and line[0] in [' ','\t']:
                             self.multi_line.append (line)
                             self.push ('... ')
                             return
                         else:
                             self.multi_line.append (line)
                             line =  '\n'.join (self.multi_line)
                             co = compile (line, repr(self), 'exec')
                             self.multi_line = []
                     else:
                         co = compile (line, repr(self), 'exec')
                 except SyntaxError:
                     why = sys.exc_info()[1]
                     if why.args[0] == 'unexpected EOF while parsing':
                         self.push ('... ')
                         self.multi_line.append (line)
                         return
                     else:
                         t,v,tb = sys.exc_info()
                         del tb
                         raise t(v)
                 exec(co in self.local_env)
                 method = 'exec'
         except:
             method = 'exception'
             self.multi_line = []
             (file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
             self.log_info('%s %s %s' %(t, v, tbinfo), 'warning')
     finally:
         sys.stdout = oldout
         sys.stderr = olderr
     self.log_info('%s:%s (%s)> %s' % (
             self.number,
             self.line_counter,
             method,
             repr(line))
             )
     self.push_with_producer (p)
     self.prompt()
开发者ID:lmcdonough,项目名称:supervisor,代码行数:78,代码来源:monitor.py


示例13: _spawn_as_child

    def _spawn_as_child(self, filename, argv):
        options = self.config.options
        # try:
        # prevent child from receiving signals sent to the
        # parent by calling os.setpgrp to create a new process
        # group for the child; this prevents, for instance,
        # the case of child processes being sent a SIGINT when
        # running supervisor in foreground mode and Ctrl-C in
        # the terminal window running supervisord is pressed.
        # Presumably it also prevents HUP, etc received by
        # supervisord from being sent to children.
        options.setpgrp()

        # set user
        try:
            setuid_msg = self.set_uid()
        except NotImplementedError:
            setuid_msg = None
        if setuid_msg:
            uid = self.config.uid
            msg = "couldn't setuid to %s: %s\n" % (uid, setuid_msg)
            options.logger.error("supervisor/process: " + msg)
            return  # finally clause will exit the child process

        # set environment
        env = os.environ.copy()
        env['SUPERVISOR_ENABLED'] = '1'
        serverurl = self.config.serverurl
        if serverurl is None:  # unset
            serverurl = self.config.options.serverurl  # might still be None
        if serverurl:
            env['SUPERVISOR_SERVER_URL'] = serverurl
        env['SUPERVISOR_PROCESS_NAME'] = self.config.name
        if self.group:
            env['SUPERVISOR_GROUP_NAME'] = self.group.config.name
        if self.config.environment is not None:
            env.update(self.config.environment)

        # Fixes bug in unicode strings env
        for key in env:
            if isinstance(key, unicode) or isinstance(env[key], unicode):
                value = env.pop(key)  # only way to update key unicode!
                key = key.encode('utf-8')
                env[key] = value.encode('utf-8')

        try:
            if self.config.umask is not None:
                options.setumask(self.config.umask)
            kwargs = dict(
                env=env,
                cwd=self.config.directory,
                redirect_stderr=self.config.redirect_stderr
            )
            try:
                self.process = options.execve(filename, argv, env)
                if self.process is None:
                    options.write(2, "child process was not spawned\n")
            except NotImplementedError:
                self.process = self.execute(filename, argv, **kwargs)
        except OSError as why:
            code = errno.errorcode.get(why.args[0], why.args[0])
            msg = "couldn't exec %s: %s\n" % (argv[0], code)
            options.write(2, "supervisor: " + msg)
            self.record_spawnerr(msg)
            self._assertInState(ProcessStates.STARTING)
            self.change_state(ProcessStates.BACKOFF)
        except:
            (file, fun, line), t, v, tbinfo = asyncore.compact_traceback()
            error = '%s, %s: file: %s line: %s' % (t, v, file, line)
            msg = "couldn't exec %s: %s\n" % (filename, error)
            options.write(2, "supervisor: " + msg)
            self.record_spawnerr(msg)
            self._assertInState(ProcessStates.STARTING)
            self.change_state(ProcessStates.BACKOFF)

        if self.process:
            self.pid = self.process.pid
            self._setup_system_resource()
            options.register_pid(self.process.pid, self)
            options.logger.info('Spawned: %r with pid %s' % (self.config.name, self.pid))
            self.delay = time.time() + self.config.startsecs
            self.spawnerr = None  # no error
开发者ID:alexsilva,项目名称:supervisor,代码行数:82,代码来源:process.py


示例14: handle_error

 def handle_error (self):      # don't close the connection on error
     file_fun_line, t, v, tbinfo = asyncore.compact_traceback()
     self.log_info(
                     'Problem with DNS lookup (%s:%s %s)' % (t, v, tbinfo),
                     'error')
开发者ID:lmcdonough,项目名称:supervisor,代码行数:5,代码来源:resolver.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python asyncore_25.loop函数代码示例发布时间:2022-05-27
下一篇:
Python events.subscribe函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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