Changeset 65e66c9 in mod_gnutls


Ignore:
Timestamp:
Nov 28, 2020, 3:46:31 PM (3 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
asyncio
Parents:
7eb4233
Message:

Turn "service ready" check functions into coroutines

This way checks that call subprocesses don't block other tasks.

Location:
test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/services.py

    r7eb4233 r65e66c9  
    5151            self.process_env = None
    5252
    53         # check: function to check if the service is up and working
     53        # check: coroutine to check if the service is up and working
    5454        self.check = check
    5555
     
    123123            if self.process and self.process.returncode is not None:
    124124                return self.process.returncode
    125             if self.check():
     125            if await self.check():
    126126                return None
    127127            else:
     
    181181        return self.config.is_file()
    182182
    183     def pidfile_check(self):
     183    async def pidfile_check(self):
    184184        """Default check method for ApacheService, waits for the PID file to
    185185        be present."""
  • test/runtest.py

    r7eb4233 r65e66c9  
    6565
    6666
    67 def check_ocsp_responder():
     67async def check_ocsp_responder():
    6868    # Check if OCSP responder works
    6969    issuer_cert = 'authority/x509.pem'
    7070    check_cert = 'authority/server/x509.pem'
    71     command = ['ocsptool', '--ask', '--nonce',
    72                '--load-issuer', issuer_cert,
    73                '--load-cert', check_cert]
    74     return subprocess.run(command).returncode == 0
    75 
    76 
    77 def check_msva():
     71    proc = await asyncio.create_subprocess_exec(
     72        'ocsptool', '--ask', '--nonce',
     73        '--load-issuer', issuer_cert, '--load-cert', check_cert)
     74    return (await proc.wait()) == 0
     75
     76
     77async def check_msva():
    7878    # Check if MSVA is up
    7979    cert_file = 'authority/client/x509.pem'
     
    8181    with open(uid_file, 'r') as file:
    8282        uid = file.read().strip()
    83         command = ['msva-query-agent', 'https', uid, 'x509pem', 'client']
    84         with open(cert_file, 'r') as cert:
    85             return subprocess.run(command, stdin=cert).returncode == 0
     83    with open(cert_file, 'r') as cert:
     84        proc = await asyncio.create_subprocess_exec(
     85            'msva-query-agent', 'https', uid, 'x509pem', 'client',
     86            stdin=cert)
     87        return (await proc.wait()) == 0
    8688
    8789
Note: See TracChangeset for help on using the changeset viewer.