本文整理汇总了Python中WatchmanInstance.setSharedInstance方法的典型用法代码示例。如果您正苦于以下问题:Python WatchmanInstance.setSharedInstance方法的具体用法?Python WatchmanInstance.setSharedInstance怎么用?Python WatchmanInstance.setSharedInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WatchmanInstance
的用法示例。
在下文中一共展示了WatchmanInstance.setSharedInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runner
# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import setSharedInstance [as 别名]
def runner():
global results_queue
global tests_queue
try:
# Start up a shared watchman instance for the tests.
inst = WatchmanInstance.Instance()
inst.start()
# Allow tests to locate this default instance
WatchmanInstance.setSharedInstance(inst)
except Exception as e:
print('This is going to suck:', e)
return
while True:
test = tests_queue.get()
try:
if test == 'terminate':
break
if Interrupt.wasInterrupted():
continue
try:
result = Result()
test.run(result)
results_queue.put(result)
except Exception as e:
print(e)
finally:
tests_queue.task_done()
inst.stop()
示例2: runner
# 需要导入模块: import WatchmanInstance [as 别名]
# 或者: from WatchmanInstance import setSharedInstance [as 别名]
def runner():
global results_queue
global tests_queue
broken = False
try:
# Start up a shared watchman instance for the tests.
inst = WatchmanInstance.Instance(
{"watcher": args.watcher}, debug_watchman=args.debug_watchman
)
inst.start()
# Allow tests to locate this default instance
WatchmanInstance.setSharedInstance(inst)
if has_asyncio:
# Each thread will have its own event loop
asyncio.set_event_loop(asyncio.new_event_loop())
except Exception as e:
print("while starting watchman: %s" % str(e))
traceback.print_exc()
broken = True
while not broken:
test = tests_queue.get()
try:
if test == "terminate":
break
if Interrupt.wasInterrupted() or broken:
continue
result = None
for attempt in range(0, args.retry_flaky + 1):
# Check liveness of the server
try:
client = pywatchman.client(timeout=3.0, sockpath=inst.getSockPath())
client.query("version")
client.close()
except Exception as exc:
print(
"Failed to connect to watchman server: %s; starting a new one"
% exc
)
try:
inst.stop()
except Exception:
pass
try:
inst = WatchmanInstance.Instance(
{"watcher": args.watcher},
debug_watchman=args.debug_watchman,
)
inst.start()
# Allow tests to locate this default instance
WatchmanInstance.setSharedInstance(inst)
except Exception as e:
print("while starting watchman: %s" % str(e))
traceback.print_exc()
broken = True
continue
try:
result = Result()
result.setAttemptNumber(attempt)
if hasattr(test, "setAttemptNumber"):
test.setAttemptNumber(attempt)
test.run(result)
if hasattr(test, "setAttemptNumber") and not result.wasSuccessful():
# Facilitate retrying this possibly flaky test
continue
break
except Exception as e:
print(e)
if hasattr(test, "setAttemptNumber") and not result.wasSuccessful():
# Facilitate retrying this possibly flaky test
continue
if (
not result.wasSuccessful()
and "TRAVIS" in os.environ
and hasattr(test, "dumpLogs")
):
test.dumpLogs()
results_queue.put(result)
finally:
tests_queue.task_done()
if not broken:
inst.stop()