forked from M-Labs/artiq
Merge branch 'master' into nac3
This commit is contained in:
commit
c3ad77ec30
|
@ -9,6 +9,7 @@ import re
|
||||||
from sipyco.pc_rpc import Server
|
from sipyco.pc_rpc import Server
|
||||||
from sipyco import common_args
|
from sipyco import common_args
|
||||||
from sipyco.logging_tools import log_with_name
|
from sipyco.logging_tools import log_with_name
|
||||||
|
from sipyco.asyncio_tools import SignalHandler
|
||||||
|
|
||||||
from artiq.coredevice.comm_mgmt import Request, Reply
|
from artiq.coredevice.comm_mgmt import Request, Reply
|
||||||
|
|
||||||
|
@ -76,6 +77,9 @@ def main():
|
||||||
common_args.init_logger_from_args(args)
|
common_args.init_logger_from_args(args)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
try:
|
||||||
|
signal_handler = SignalHandler()
|
||||||
|
signal_handler.setup()
|
||||||
try:
|
try:
|
||||||
get_logs_task = asyncio.ensure_future(
|
get_logs_task = asyncio.ensure_future(
|
||||||
get_logs_sim(args.core_addr) if args.simulation else get_logs(args.core_addr))
|
get_logs_sim(args.core_addr) if args.simulation else get_logs(args.core_addr))
|
||||||
|
@ -83,7 +87,11 @@ def main():
|
||||||
server = Server({"corelog": PingTarget()}, None, True)
|
server = Server({"corelog": PingTarget()}, None, True)
|
||||||
loop.run_until_complete(server.start(common_args.bind_address_from_args(args), args.port))
|
loop.run_until_complete(server.start(common_args.bind_address_from_args(args), args.port))
|
||||||
try:
|
try:
|
||||||
loop.run_until_complete(server.wait_terminate())
|
_, pending = loop.run_until_complete(asyncio.wait(
|
||||||
|
[signal_handler.wait_terminate(), server.wait_terminate()],
|
||||||
|
return_when=asyncio.FIRST_COMPLETED))
|
||||||
|
for task in pending:
|
||||||
|
task.cancel()
|
||||||
finally:
|
finally:
|
||||||
loop.run_until_complete(server.stop())
|
loop.run_until_complete(server.stop())
|
||||||
finally:
|
finally:
|
||||||
|
@ -92,6 +100,8 @@ def main():
|
||||||
loop.run_until_complete(get_logs_task)
|
loop.run_until_complete(get_logs_task)
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
pass
|
pass
|
||||||
|
finally:
|
||||||
|
signal_handler.teardown()
|
||||||
finally:
|
finally:
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import asyncio
|
||||||
import struct
|
import struct
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from sipyco.asyncio_tools import AsyncioServer
|
from sipyco.asyncio_tools import AsyncioServer, SignalHandler
|
||||||
from sipyco.pc_rpc import Server
|
from sipyco.pc_rpc import Server
|
||||||
from sipyco import common_args
|
from sipyco import common_args
|
||||||
|
|
||||||
|
@ -197,6 +197,9 @@ def main():
|
||||||
bind_address = common_args.bind_address_from_args(args)
|
bind_address = common_args.bind_address_from_args(args)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
try:
|
||||||
|
signal_handler = SignalHandler()
|
||||||
|
signal_handler.setup()
|
||||||
try:
|
try:
|
||||||
monitor_mux = MonitorMux()
|
monitor_mux = MonitorMux()
|
||||||
comm_moninj = CommMonInj(monitor_mux.monitor_cb, monitor_mux.injection_status_cb)
|
comm_moninj = CommMonInj(monitor_mux.monitor_cb, monitor_mux.injection_status_cb)
|
||||||
|
@ -209,13 +212,19 @@ def main():
|
||||||
server = Server({"moninj_proxy": PingTarget()}, None, True)
|
server = Server({"moninj_proxy": PingTarget()}, None, True)
|
||||||
loop.run_until_complete(server.start(bind_address, args.port_control))
|
loop.run_until_complete(server.start(bind_address, args.port_control))
|
||||||
try:
|
try:
|
||||||
loop.run_until_complete(server.wait_terminate())
|
_, pending = loop.run_until_complete(asyncio.wait(
|
||||||
|
[signal_handler.wait_terminate(), server.wait_terminate()],
|
||||||
|
return_when=asyncio.FIRST_COMPLETED))
|
||||||
|
for task in pending:
|
||||||
|
task.cancel()
|
||||||
finally:
|
finally:
|
||||||
loop.run_until_complete(server.stop())
|
loop.run_until_complete(server.stop())
|
||||||
finally:
|
finally:
|
||||||
loop.run_until_complete(proxy_server.stop())
|
loop.run_until_complete(proxy_server.stop())
|
||||||
finally:
|
finally:
|
||||||
loop.run_until_complete(comm_moninj.close())
|
loop.run_until_complete(comm_moninj.close())
|
||||||
|
finally:
|
||||||
|
signal_handler.teardown()
|
||||||
finally:
|
finally:
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from sipyco.sync_struct import Publisher
|
||||||
from sipyco.logging_tools import Server as LoggingServer
|
from sipyco.logging_tools import Server as LoggingServer
|
||||||
from sipyco.broadcast import Broadcaster
|
from sipyco.broadcast import Broadcaster
|
||||||
from sipyco import common_args
|
from sipyco import common_args
|
||||||
from sipyco.asyncio_tools import atexit_register_coroutine
|
from sipyco.asyncio_tools import atexit_register_coroutine, SignalHandler
|
||||||
|
|
||||||
from artiq import __version__ as artiq_version
|
from artiq import __version__ as artiq_version
|
||||||
from artiq.master.log import log_args, init_log
|
from artiq.master.log import log_args, init_log
|
||||||
|
@ -76,6 +76,9 @@ def main():
|
||||||
log_forwarder = init_log(args)
|
log_forwarder = init_log(args)
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
atexit.register(loop.close)
|
atexit.register(loop.close)
|
||||||
|
signal_handler = SignalHandler()
|
||||||
|
signal_handler.setup()
|
||||||
|
atexit.register(signal_handler.teardown)
|
||||||
bind = common_args.bind_address_from_args(args)
|
bind = common_args.bind_address_from_args(args)
|
||||||
|
|
||||||
server_broadcast = Broadcaster()
|
server_broadcast = Broadcaster()
|
||||||
|
@ -155,7 +158,7 @@ def main():
|
||||||
atexit_register_coroutine(server_logging.stop)
|
atexit_register_coroutine(server_logging.stop)
|
||||||
|
|
||||||
print("ARTIQ master is now ready.")
|
print("ARTIQ master is now ready.")
|
||||||
loop.run_forever()
|
loop.run_until_complete(signal_handler.wait_terminate())
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
from sipyco.asyncio_tools import SignalHandler
|
||||||
|
|
||||||
from artiq.coredevice.comm_moninj import *
|
from artiq.coredevice.comm_moninj import *
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +22,9 @@ def main():
|
||||||
args = get_argparser().parse_args()
|
args = get_argparser().parse_args()
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
try:
|
||||||
|
signal_handler = SignalHandler()
|
||||||
|
signal_handler.setup()
|
||||||
try:
|
try:
|
||||||
comm = CommMonInj(
|
comm = CommMonInj(
|
||||||
lambda channel, probe, value: print("0x{:06x}: {}".format(channel, value)),
|
lambda channel, probe, value: print("0x{:06x}: {}".format(channel, value)),
|
||||||
|
@ -28,9 +33,11 @@ def main():
|
||||||
try:
|
try:
|
||||||
for channel in args.channel:
|
for channel in args.channel:
|
||||||
comm.monitor_probe(True, channel, 0)
|
comm.monitor_probe(True, channel, 0)
|
||||||
loop.run_forever()
|
loop.run_until_complete(signal_handler.wait_terminate())
|
||||||
finally:
|
finally:
|
||||||
loop.run_until_complete(comm.close())
|
loop.run_until_complete(comm.close())
|
||||||
|
finally:
|
||||||
|
signal_handler.teardown()
|
||||||
finally:
|
finally:
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue