(self)
| 95 | app.run(host=API_HOST, port=API_PORT, threaded=API_THREADED, use_reloader=False) |
| 96 | |
| 97 | def run(self): |
| 98 | global tester_process, getter_process, server_process |
| 99 | try: |
| 100 | logger.info('starting proxypool...') |
| 101 | if ENABLE_TESTER: |
| 102 | tester_process = multiprocessing.Process( |
| 103 | target=self.run_tester) |
| 104 | logger.info(f'starting tester, pid {tester_process.pid}...') |
| 105 | tester_process.start() |
| 106 | |
| 107 | if ENABLE_GETTER: |
| 108 | getter_process = multiprocessing.Process( |
| 109 | target=self.run_getter) |
| 110 | logger.info(f'starting getter, pid {getter_process.pid}...') |
| 111 | getter_process.start() |
| 112 | |
| 113 | if ENABLE_SERVER: |
| 114 | server_process = multiprocessing.Process( |
| 115 | target=self.run_server) |
| 116 | logger.info(f'starting server, pid {server_process.pid}...') |
| 117 | server_process.start() |
| 118 | |
| 119 | tester_process and tester_process.join() |
| 120 | getter_process and getter_process.join() |
| 121 | server_process and server_process.join() |
| 122 | except KeyboardInterrupt: |
| 123 | logger.info('received keyboard interrupt signal') |
| 124 | tester_process and tester_process.terminate() |
| 125 | getter_process and getter_process.terminate() |
| 126 | server_process and server_process.terminate() |
| 127 | finally: |
| 128 | # must call join method before calling is_alive |
| 129 | tester_process and tester_process.join() |
| 130 | getter_process and getter_process.join() |
| 131 | server_process and server_process.join() |
| 132 | if tester_process: |
| 133 | logger.info( |
| 134 | f'tester is {"alive" if tester_process.is_alive() else "dead"}') |
| 135 | if getter_process: |
| 136 | logger.info( |
| 137 | f'getter is {"alive" if getter_process.is_alive() else "dead"}') |
| 138 | if server_process: |
| 139 | logger.info( |
| 140 | f'server is {"alive" if server_process.is_alive() else "dead"}') |
| 141 | logger.info('proxy terminated') |
| 142 | |
| 143 | |
| 144 | if __name__ == '__main__': |
no outgoing calls
no test coverage detected