mirror of
https://github.com/certbot/certbot.git
synced 2026-06-06 15:22:38 -04:00
Let tests specify how long parent waits for child process
This commit is contained in:
parent
ff3c0c6689
commit
41284ffc0a
2 changed files with 5 additions and 4 deletions
|
|
@ -310,16 +310,17 @@ class StandaloneAuthenticator(object):
|
|||
new_ctx.use_privatekey(self.private_key)
|
||||
connection.set_context(new_ctx)
|
||||
|
||||
def do_parent_process(self, port):
|
||||
def do_parent_process(self, port, delay_amount=5):
|
||||
"""Perform the parent process side of the TCP listener task. This
|
||||
should only be called by start_listener()."""
|
||||
should only be called by start_listener(). We will wait up to
|
||||
delay_amount seconds to hear from the child process via a signal."""
|
||||
|
||||
signal.signal(signal.SIGIO, self.client_signal_handler)
|
||||
signal.signal(signal.SIGUSR1, self.client_signal_handler)
|
||||
signal.signal(signal.SIGUSR2, self.client_signal_handler)
|
||||
display = zope.component.getUtility(interfaces.IDisplay)
|
||||
start_time = time.time()
|
||||
while time.time() < start_time + 5:
|
||||
while time.time() < start_time + delay_amount:
|
||||
if self.subproc_ready:
|
||||
return True
|
||||
if self.subproc_inuse:
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ class DoParentProcessTest(unittest.TestCase):
|
|||
@mock.patch("letsencrypt.client.standalone_authenticator.zope.component.getUtility")
|
||||
def test_do_parent_process_timeout(self, mock_getUtility, mock_signal):
|
||||
# Times out in 5 seconds and returns False.
|
||||
result = self.authenticator.do_parent_process(1717)
|
||||
result = self.authenticator.do_parent_process(1717, delay_amount=1)
|
||||
self.assertFalse(result)
|
||||
self.assertEqual(mock_signal.call_count, 3)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue