1#!/usr/bin/env python3 2# 3# Copyright (C) 2018 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); you may not 6# use this file except in compliance with the License. You may obtain a copy of 7# the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14# License for the specific language governing permissions and limitations under 15# the License. 16"""Script to start running server that manages a shared BigqueryLoggerQueue.""" 17 18import sys 19from multiprocessing.managers import BaseManager 20 21from acts.controllers.buds_lib.data_storage.bigquery.bigquery_logger_queue import BigqueryLoggerQueue 22 23 24def start_queue_server(queue_size, ip_address, port, authkey): 25 queue = BigqueryLoggerQueue(size=int(queue_size)) 26 BaseManager.register('get_queue', callable=lambda: queue) 27 m = BaseManager(address=(ip_address, int(port)), authkey=authkey) 28 s = m.get_server() 29 30 print('starting server...') 31 s.serve_forever() 32 33 34def main(): 35 queue_size, ip_address, port, authkey = sys.argv[1:] 36 start_queue_server(queue_size, ip_address, port, authkey) 37 38 39if __name__ == '__main__': 40 main() 41