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


Python Observer.daemon方法代码示例

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


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

示例1: _loop_darwin

# 需要导入模块: from fsevents import Observer [as 别名]
# 或者: from fsevents.Observer import daemon [as 别名]
    def _loop_darwin(self): # pragma: no cover
        """loop implementation for darwin platform"""
        from fsevents import Observer #pylint: disable=F0401
        from fsevents import Stream #pylint: disable=F0401
        from fsevents import IN_MODIFY #pylint: disable=F0401

        observer = Observer()
        handler = self._handle
        def fsevent_callback(event):
            if event.mask == IN_MODIFY:
                handler(event)

        for watch_this in self.watch_dirs:
            stream = Stream(fsevent_callback, watch_this, file_events=True)
            observer.schedule(stream)

        observer.daemon = True
        observer.start()
        try:
            # hack to keep main thread running...
            import time
            while True:
                time.sleep(99999)
        except (SystemExit, KeyboardInterrupt):
            pass
开发者ID:JohannesBuchner,项目名称:doit,代码行数:27,代码来源:filewatch.py

示例2: watch_files

# 需要导入模块: from fsevents import Observer [as 别名]
# 或者: from fsevents.Observer import daemon [as 别名]
def watch_files(paths):
    global observer
    observer = Observer()
    stream = Stream(update_file, file_events=True, *paths)
    observer.schedule(stream)
    log.info("Starting observer")
    observer.daemon = True
    observer.start()
    log.info("Observer started")
开发者ID:Mondego,项目名称:pyreco,代码行数:11,代码来源:allPythonContent.py

示例3: loop

# 需要导入模块: from fsevents import Observer [as 别名]
# 或者: from fsevents.Observer import daemon [as 别名]
 def loop(self):
     observer = Observer()
     observer.schedule(self.stream)
     observer.daemon = True
     observer.start()
     try:
         while True:
             # Cannot use observer.join() as it is not interrupted by
             # Ctrl-C
             time.sleep(10000)
     finally:
         observer.unschedule(self.stream)
         observer.stop()
开发者ID:tguigue,项目名称:calibre,代码行数:15,代码来源:auto_reload.py

示例4: loop

# 需要导入模块: from fsevents import Observer [as 别名]
# 或者: from fsevents.Observer import daemon [as 别名]
 def loop(self):
     observer = Observer()
     observer.schedule(self.stream)
     observer.daemon = True
     observer.start()
     try:
         while True:
             try:
                 # Cannot use blocking get() as it is not interrupted by
                 # Ctrl-C
                 if self.wait_queue.get(10000) is True:
                     self.force_restart()
             except Empty:
                 pass
     finally:
         observer.unschedule(self.stream)
         observer.stop()
开发者ID:AEliu,项目名称:calibre,代码行数:19,代码来源:auto_reload.py

示例5: _loop_darwin

# 需要导入模块: from fsevents import Observer [as 别名]
# 或者: from fsevents.Observer import daemon [as 别名]
    def _loop_darwin(self): # pragma: no cover
        """loop implementation for darwin platform"""
        from fsevents import Observer #pylint: disable=F0401
        from fsevents import Stream #pylint: disable=F0401
        from fsevents import IN_MODIFY #pylint: disable=F0401

        observer = Observer()
        handler = self._handle
        def fsevent_callback(event):
            if event.mask == IN_MODIFY:
                handler(event)

        for watch_this in self.watch_dirs:
            stream = Stream(fsevent_callback, watch_this, file_events=True)
            observer.schedule(stream)

        observer.daemon = True
        observer.run()
开发者ID:GadgetSteve,项目名称:doit,代码行数:20,代码来源:filewatch.py

示例6: Observer

# 需要导入模块: from fsevents import Observer [as 别名]
# 或者: from fsevents.Observer import daemon [as 别名]
import os
import sys

from fsevents import Observer, Stream

observer = Observer()
observer.daemon = True

def callback(event):
	observer.stop()
	print(event.name, 'changed, reloading...')
	os.execv(sys.argv[0], sys.argv)

def init():
	paths = []
	for module in sys.modules.values():
		try:
			pathname = os.path.dirname(module.__file__)
		except AttributeError:
			continue
		paths.append(pathname)

	observer.start()
	stream = Stream(callback, *paths, file_events=True)
	observer.schedule(stream)
开发者ID:jmw327,项目名称:pigwig,代码行数:27,代码来源:reloader_osx.py


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