mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-20 00:46:30 +08:00
45 lines
1.1 KiB
Python
Executable File
45 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import asyncio
|
|
|
|
from artiq.management.pc_rpc import Server
|
|
from artiq.management.scheduler import Scheduler
|
|
|
|
|
|
class Master:
|
|
def __init__(self, scheduler):
|
|
self.scheduler = scheduler
|
|
self.terminate_notify = asyncio.Semaphore(0)
|
|
|
|
@asyncio.coroutine
|
|
def wait_quit(self):
|
|
yield from self.terminate_notify.acquire()
|
|
|
|
def quit(self):
|
|
self.terminate_notify.release()
|
|
|
|
def run_once(self, run_params, timeout):
|
|
self.scheduler.run_once(run_params, timeout)
|
|
|
|
|
|
def main():
|
|
loop = asyncio.get_event_loop()
|
|
try:
|
|
scheduler = Scheduler()
|
|
loop.run_until_complete(scheduler.start())
|
|
try:
|
|
master = Master(scheduler)
|
|
server = Server(master)
|
|
loop.run_until_complete(server.start("::1", 8888))
|
|
try:
|
|
loop.run_until_complete(master.wait_quit())
|
|
finally:
|
|
loop.run_until_complete(server.stop())
|
|
finally:
|
|
loop.run_until_complete(scheduler.stop())
|
|
finally:
|
|
loop.close()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|