当前位置: 首页>>代码示例>>Python>>正文


Python BackdoorServer.close方法代码示例

本文整理汇总了Python中gevent.backdoor.BackdoorServer.close方法的典型用法代码示例。如果您正苦于以下问题:Python BackdoorServer.close方法的具体用法?Python BackdoorServer.close怎么用?Python BackdoorServer.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gevent.backdoor.BackdoorServer的用法示例。


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

示例1: Warpgate

# 需要导入模块: from gevent.backdoor import BackdoorServer [as 别名]
# 或者: from gevent.backdoor.BackdoorServer import close [as 别名]
class Warpgate(object):

    def init(self):
        import options
        from UnityEngine import Debug

        L = lambda s: Debug.Log("PyWrap: " + s)
        L("init")

        self.events = []

        # should set them
        options.no_update
        options.show_hidden_mode

        options.freeplay = False

        if options.no_update:
            import autoupdate
            autoupdate.Autoupdate = autoupdate.DummyAutoupdate

        L("before gevent")
        from gevent import monkey
        monkey.patch_socket()
        monkey.patch_os()
        monkey.patch_select()
        L("after gevent")

        from game import autoenv
        autoenv.init('Client')

        import thb.ui.ui_meta  # noqa, init ui_meta

        from client.core.executive import Executive
        self.executive = ExecutiveWrapper(Executive, self)

    def get_events(self):
        l = self.events
        self.events = []
        return l

    def start_backdoor(self):
        from gevent.backdoor import BackdoorServer
        import gevent
        self.bds = BackdoorServer(('127.0.0.1', 12345))
        self.gr_bds = gevent.spawn(self.bds.serve_forever)

    def stop_backdoor(self):
        self.gr_bds.kill()
        self.bds.close()

    def shutdown(self):
        from client.core.executive import Executive
        if Executive.state == 'connected':
            Executive.disconnect()

    def queue_system_event(self, evt_name, arg=None):
        self.events.append(('system_event', evt_name, arg))
开发者ID:feisuzhu,项目名称:thbattle,代码行数:60,代码来源:warpgate.py

示例2: DebugService

# 需要导入模块: from gevent.backdoor import BackdoorServer [as 别名]
# 或者: from gevent.backdoor.BackdoorServer import close [as 别名]
class DebugService(RpcService):
    def __init__(self):
        super(DebugService, self).__init__()
        self.dispatcher = None
        self.backdoor_server = None

    def initialize(self, context):
        self.dispatcher = context.dispatcher

    @private
    def dump_stacks(self):
        from greenlet import greenlet

        # If greenlet is present, let's dump each greenlet stack
        dump = []
        for ob in gc.get_objects():
            if not isinstance(ob, greenlet):
                continue
            if not ob:
                continue   # not running anymore or not started

            dump.append(''.join(traceback.format_stack(ob.gr_frame)))

        return dump

    @private
    def attach(self, host, port):
        sys.path.append('/usr/local/lib/dispatcher/pydev')

        import pydevd
        pydevd.settrace(host, port=port, stdoutToServer=True, stderrToServer=True)

    @private
    def detach(self):
        import pydevd
        pydevd.stoptrace()

    @private
    def set_tasks_debug(self, host, port, tasks=None):
        self.dispatcher.balancer.debugger = (host, port)
        self.dispatcher.balancer.debugged_tasks = tasks or ['*']

    @private
    def cancel_tasks_debug(self):
        self.dispatcher.balancer.debugger = None
        self.dispatcher.balancer.debugged_tasks = None

    @private
    def start_backdoor(self):
        self.backdoor_server = BackdoorServer(
            ('127.0.0.1', 9999),
            banner='DebugService backdoor server',
            locals={
                'dispatcher': self.dispatcher
            }
        )

        gevent.spawn(self.backdoor_server.serve_forever)

    @private
    def stop_backdoor(self):
        if self.backdoor_server:
            self.backdoor_server.close()
            self.backdoor_server = None

    @private
    def start_tracemalloc(self):
        tracemalloc.start()

    @private
    def stop_tracemalloc(self):
        tracemalloc.stop()

    @private
    def snapshot_tracemalloc(self):
        snap = tracemalloc.take_snapshot()
        return [str(i) for i in snap.statistics('lineno')[:100]]
开发者ID:erinix,项目名称:middleware,代码行数:79,代码来源:services.py

示例3: DebugService

# 需要导入模块: from gevent.backdoor import BackdoorServer [as 别名]
# 或者: from gevent.backdoor.BackdoorServer import close [as 别名]
class DebugService(RpcService):
    def __init__(self, gevent=False, builtins=None):
        self.gevent = gevent
        self.backdoor_locals = builtins or {}
        self.backdoor_server = None

    @private
    def attach(self, host, port):
        import pydevd
        pydevd.settrace(host, port=port, stdoutToServer=True, stderrToServer=True)

    @private
    def detach(self):
        import pydevd
        pydevd.stoptrace()

    @private
    def dump_stacks(self):
        if self.gevent:
            from greenlet import greenlet

            # If greenlet is present, let's dump each greenlet stack
            dump = []
            for ob in gc.get_objects():
                if not isinstance(ob, greenlet):
                    continue
                if not ob:
                    continue   # not running anymore or not started

                dump.append(''.join(traceback.format_stack(ob.gr_frame)))

            return dump
        else:
            dump = []
            for frame in list(sys._current_frames().values()):
                dump.append(''.join(traceback.format_stack(frame)))

            return dump

    @private
    def start_backdoor(self):
        if not self.gevent:
            raise RpcException(errno.ENOTSUP, 'Not supported')

        from gevent import spawn
        from gevent.backdoor import BackdoorServer
        self.backdoor_server = BackdoorServer(
            ('127.0.0.1', 9999),
            banner='DebugService backdoor server',
            locals=self.backdoor_locals
        )

        spawn(self.backdoor_server.serve_forever())

    @private
    def stop_backdoor(self):
        if not self.gevent:
            raise RpcException(errno.ENOTSUP, 'Not supported')

        if self.backdoor_server:
            self.backdoor_server.close()
            self.backdoor_server = None
开发者ID:650elx,项目名称:middleware,代码行数:64,代码来源:debug.py


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