forked from M-Labs/artiq
1
0
Fork 0

master: add terminate API

This commit is contained in:
Egor Savkin 2023-04-18 15:03:06 +08:00 committed by GitHub
parent 918d30b900
commit aed47d79ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 6 deletions

View File

@ -125,6 +125,9 @@ def get_argparser():
"ls", help="list a directory on the master")
parser_ls.add_argument("directory", default="", nargs="?")
subparsers.add_parser(
"terminate", help="terminate the ARTIQ master")
common_args.verbosity_args(parser)
return parser
@ -195,6 +198,10 @@ def _action_ls(remote, args):
print(name)
def _action_terminate(remote, _args):
remote.terminate()
def _show_schedule(schedule):
clear_screen()
if schedule:
@ -319,7 +326,8 @@ def main():
"del_dataset": "master_dataset_db",
"scan_devices": "master_device_db",
"scan_repository": "master_experiment_db",
"ls": "master_experiment_db"
"ls": "master_experiment_db",
"terminate": "master_terminate",
}[action]
remote = Client(args.server, port, target_name)
try:

View File

@ -4,6 +4,7 @@ import asyncio
import argparse
import atexit
import logging
from types import SimpleNamespace
from sipyco.pc_rpc import Server as RPCServer
from sipyco.sync_struct import Publisher
@ -133,12 +134,16 @@ def main():
})
experiment_db.scan_repository_async(loop=loop)
signal_handler_task = loop.create_task(signal_handler.wait_terminate())
master_terminate = SimpleNamespace(terminate=lambda: signal_handler_task.cancel())
server_control = RPCServer({
"master_config": config,
"master_device_db": device_db,
"master_dataset_db": dataset_db,
"master_schedule": scheduler,
"master_experiment_db": experiment_db
"master_experiment_db": experiment_db,
"master_terminate": master_terminate
}, allow_parallel=True)
loop.run_until_complete(server_control.start(
bind, args.port_control))
@ -161,7 +166,11 @@ def main():
atexit_register_coroutine(server_logging.stop, loop=loop)
print("ARTIQ master is now ready.")
loop.run_until_complete(signal_handler.wait_terminate())
try:
loop.run_until_complete(signal_handler_task)
except asyncio.CancelledError:
pass
if __name__ == "__main__":
main()

View File

@ -89,11 +89,11 @@
]
},
"locked": {
"lastModified": 1673433867,
"narHash": "sha256-a7Oq35YoDzPtISbqAsaT+2/v15HZ7G1q0ukXmKWdb7Q=",
"lastModified": 1681290481,
"narHash": "sha256-VEZcGhbtJGonRrrWi31evNDVSerlLjEPL0MZGm9VlB8=",
"owner": "m-labs",
"repo": "sipyco",
"rev": "38f8f4185d7db6b68bd7f71546da9077b1e2561c",
"rev": "727631ada6e59dc6ef0ad50bfcc376d2ffe805aa",
"type": "github"
},
"original": {