def se_requester(self):
"""
While the reactor is polling, we can't make any requests. So have the
reactor itself make the request and store the result.
"""
logger.debug('requester called; spawning process')
# since Python is single-threaded and Twisted is just event-based,
# we can't do a request and run the redirector from the same script.
# Best choice is to used popen to run an external script to do the
# redirect.
url = 'http://127.0.0.1:%d' % self.cls.bind_port
path = os.path.join(os.path.dirname(__file__), 'requester.py')
self.poller = subprocess.Popen(
[sys.executable, path, url, '/bar/baz', '/vault-redirector-health'],
stdout=subprocess.PIPE,
universal_newlines=True
)
# run a poller loop to check for process stop and get results
self.poller_check_task = task.LoopingCall(self.check_request)
self.poller_check_task.clock = self.cls.reactor
self.poller_check_task.start(0.5)
logger.debug('poller_check_task started')
test_redirector.py 文件源码
python
阅读 31
收藏 0
点赞 0
评论 0
评论列表
文章目录