Search notes:

Python standard library: contextlilb.contextmanager

contextmanager is a decorator. With this decorator, a function is turned into a context manager that can be used in a with statement.
from contextlib import contextmanager

@contextmanager
def aResource():

    print('Acquiring a resource')
    try:
       yield

    finally:
       print('releasing the resource')

with aResource():
     print('  do something while the resource is acquired')
Github repository about-Python, path: /standard-library/contextlib/contextmanager.py

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...', 1758198433, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/standard-library/contextlib/contextmanager(49): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78