Search notes:

Python: asyncio.create_subprocess_shell

import asyncio

async def run_command(cmd):

    print(f'Running {cmd}')

    proc = await asyncio.create_subprocess_shell(
        cmd,
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.PIPE)

    STDOUT, STDERR = await proc.communicate()

    print(f'[{cmd!r} exited with {proc.returncode}]')

    if STDOUT:
       print(f'{cmd} returned {STDOUT.decode()}')

    if STDERR:
       print(f'Error: {STDERR.decode()}')

async def run_commands_in_parallel():
    await asyncio.gather(
       run_command("find ~ -type f -name '*.txt' | wc -l"),
       run_command("find ~ -type f -name '*.py'  | wc -l"),
       run_command("ps -ef | grep find")
    )
      
asyncio.run(run_commands_in_parallel())

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758203861, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/standard-library/asyncio/create_subprocess_shell(58): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78