本文整理匯總了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()