Ejemplo n.º 1
0
    def prepare(self):
        self.lrpc = get_lrpc()
        self.snapshot_rpc = snapshot_service_pb2.SnapshotService(self.lrpc)
        self.world_rpc = world_service_pb2.WorldService(self.lrpc)
        self.lrpc.add_to_event_loop()

        self.snapshots = None
        self.snapshots_cache = None
Ejemplo n.º 2
0
def run_event_loop(loop):
    global tracker_rpc, task_rpc
    asyncio.set_event_loop(loop)

    lrpc = get_lrpc()
    tracker_rpc = crowd_task_pb2.TrackerService(lrpc)
    task_rpc = task_service_pb2.TaskService(lrpc)

    lrpc.add_to_event_loop()
    loop.run_forever()
                    do_accept = None
                    while do_accept not in ["", "y", "n", "q"]:
                        do_accept = input("Accept? (Y/n/i/q)")
                        if do_accept == "i":
                            tracker_rpc.Activate(task_template.base_task)

                    if do_accept == "q":
                        print("[main] quitting")
                        return
                    elif do_accept == "n":
                        continue

                req.tasks.extend([task_template])
                req.save = True
                req.return_processed = True
                response = await task_rpc.Submit(req)

                print('Saved the task...')
                await asyncio.sleep(0.2)
                break # Only allow one annotation per task

    print("[main] done")

lrpc = get_lrpc()
tracker_rpc = crowd_task_pb2.TrackerService(lrpc)
task_rpc = task_service_pb2.TaskService(lrpc)

lrpc.add_to_event_loop()
# from util import ipyloop
asyncio.get_event_loop().run_until_complete(main())