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


Python Watcher.start方法代码示例

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


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

示例1: SomeWatcher

# 需要导入模块: from circus.watcher import Watcher [as 别名]
# 或者: from circus.watcher.Watcher import start [as 别名]
class SomeWatcher(threading.Thread):

    def __init__(self):
        threading.Thread.__init__(self)
        self.stream = QueueStream()
        self.loop = self.watcher = None

    def run(self):
        qstream = {'stream': self.stream}
        old_environ = os.environ
        old_paths = sys.path[:]
        try:
            sys.path = ['XYZ']
            os.environ = {'COCONUTS': 'MIGRATE'}
            cmd = ('%s -c "import sys; '
                   'sys.stdout.write(\':\'.join(sys.path)); '
                   ' sys.stdout.flush()"') % sys.executable

            self.loop = ioloop.IOLoop.instance()
            self.watcher = Watcher('xx', cmd, copy_env=True, copy_path=True,
                                   stdout_stream=qstream, loop=self.loop)
            self.watcher.start()
            self.loop.start()
        finally:
            os.environ = old_environ
            sys.path[:] = old_paths

    def stop(self):
        if self.loop is not None:
            self.loop.stop()
        if self.watcher is not None:
            self.watcher.stop()
        self.join()
开发者ID:ionrock,项目名称:circus,代码行数:35,代码来源:test_watcher.py

示例2: SomeWatcher

# 需要导入模块: from circus.watcher import Watcher [as 别名]
# 或者: from circus.watcher.Watcher import start [as 别名]
class SomeWatcher(threading.Thread):
    def __init__(self, **kw):
        threading.Thread.__init__(self)
        self.stream = QueueStream()
        self.loop = self.watcher = None
        self.kw = kw

    def run(self):
        qstream = {"stream": self.stream}
        old_environ = os.environ
        old_paths = sys.path[:]
        try:
            sys.path = ["XYZ"]
            os.environ = {"COCONUTS": "MIGRATE"}
            cmd = (
                '%s -c "import sys; ' "sys.stdout.write(':'.join(sys.path)); " ' sys.stdout.flush()"'
            ) % sys.executable

            self.loop = ioloop.IOLoop()
            self.watcher = Watcher(
                "xx", cmd, copy_env=True, copy_path=True, stdout_stream=qstream, loop=self.loop, **self.kw
            )
            self.watcher.start()
            self.loop.start()
        finally:
            os.environ = old_environ
            sys.path[:] = old_paths

    def stop(self):
        if self.loop is not None:
            self.loop.stop()
        if self.watcher is not None:
            self.watcher.stop()
        self.join()
开发者ID:victorpoluceno,项目名称:circus,代码行数:36,代码来源:test_watcher.py

示例3: SomeWatcher

# 需要导入模块: from circus.watcher import Watcher [as 别名]
# 或者: from circus.watcher.Watcher import start [as 别名]
class SomeWatcher(object):

    def __init__(self, loop=None, **kw):
        self.stream = QueueStream()
        self.watcher = None
        self.kw = kw
        if loop is None:
            self.loop = tornado.ioloop.IOLoop.instance()
        else:
            self.loop = loop

    @tornado.gen.coroutine
    def run(self):
        qstream = {'stream': self.stream}
        old_environ = os.environ
        old_paths = sys.path[:]
        try:
            sys.path = ['XYZ']
            os.environ = {'COCONUTS': 'MIGRATE'}
            cmd = ('%s -c "import sys; '
                   'sys.stdout.write(\':\'.join(sys.path)); '
                   ' sys.stdout.flush()"') % sys.executable

            self.watcher = Watcher('xx', cmd, copy_env=True, copy_path=True,
                                   stdout_stream=qstream, loop=self.loop,
                                   **self.kw)
            yield self.watcher.start()
        finally:
            os.environ = old_environ
            sys.path[:] = old_paths

    @tornado.gen.coroutine
    def stop(self):
        if self.watcher is not None:
            yield self.watcher.stop()
开发者ID:decklord,项目名称:circus,代码行数:37,代码来源:test_watcher.py

示例4: test_copy_path

# 需要导入模块: from circus.watcher import Watcher [as 别名]
# 或者: from circus.watcher.Watcher import start [as 别名]
 def test_copy_path(self):
     stream = QueueStream()
     qstream = {'stream': stream}
     old_environ = os.environ
     old_paths = sys.path[:]
     try:
         sys.path = ['XYZ']
         os.environ = {'COCONUTS': 'MIGRATE'}
         cmd = ('%s -c "import sys; '
                'sys.stdout.write(\':\'.join(sys.path)); '
                ' sys.stdout.flush()"') % sys.executable
         watcher = Watcher('xx', cmd, copy_env=True, copy_path=True,
                           stdout_stream=qstream)
         watcher.start()
         time.sleep(3.)
         watcher.stop()
         data = [v for k, v in stream.get().items()][1]
         data = ''.join(data)
         self.assertTrue('XYZ' in data, data)
     finally:
         os.environ = old_environ
         sys.path[:] = old_paths
开发者ID:tomquas,项目名称:circus,代码行数:24,代码来源:test_watcher.py


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