mirror of
https://github.com/wassname/ray.git
synced 2026-07-19 11:27:32 +08:00
* Initial scheduler commit * global scheduler * add global scheduler * Implement global scheduler skeleton. * Formatting. * Allow local scheduler to be started without a connection to redis so that we can test it without a global scheduler. * Fail if there are no local schedulers when the global scheduler receives a task. * Initialize uninitialized value and formatting fix. * Generalize local scheduler table to db client table. * Remove code duplication in local scheduler and add flag for whether a task came from the global scheduler or not. * Queue task specs in the local scheduler instead of tasks. * Simple global scheduler tests, including valgrind. * Factor out functions for starting processes. * Fixes.
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
from __future__ import print_function
|
|
|
|
import os
|
|
import subprocess
|
|
import time
|
|
|
|
def start_global_scheduler(redis_address, use_valgrind=False, use_profiler=False):
|
|
"""Start a global scheduler process.
|
|
|
|
Args:
|
|
redis_address (str): The address of the Redis instance.
|
|
use_valgrind (bool): True if the global scheduler should be started inside
|
|
of valgrind. If this is True, use_profiler must be False.
|
|
use_profiler (bool): True if the global scheduler should be started inside a
|
|
profiler. If this is True, use_valgrind must be False.
|
|
|
|
Return:
|
|
The process ID of the global scheduler process.
|
|
"""
|
|
if use_valgrind and use_profiler:
|
|
raise Exception("Cannot use valgrind and profiler at the same time.")
|
|
global_scheduler_executable = os.path.join(os.path.abspath(os.path.dirname(__file__)), "../../build/global_scheduler")
|
|
command = [global_scheduler_executable, "-r", redis_address]
|
|
if use_valgrind:
|
|
pid = subprocess.Popen(["valgrind", "--track-origins=yes", "--leak-check=full", "--show-leak-kinds=all", "--error-exitcode=1"] + command)
|
|
time.sleep(1.0)
|
|
elif use_profiler:
|
|
pid = subprocess.Popen(["valgrind", "--tool=callgrind"] + command)
|
|
time.sleep(1.0)
|
|
else:
|
|
pid = subprocess.Popen(command)
|
|
time.sleep(0.1)
|
|
return pid
|