本文整理汇总了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
示例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")
示例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()
示例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()
示例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()
示例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)