|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /lib/python3/dist-packages/certbot/__pycache__/ |
Upload File : |
U
�]� � @ s� d Z ddlZddlZddlZddlZddlmZmZmZm Z m
Z
ddlmZ ddl
mZ e�e�Zejdkr�ejgZejejejejfD ]Ze�e�ejkr�e�e� q�ng ZG dd� de�ZG d d
� d
e�ZdS )zBRegisters functions to be called if an exception or signal occurs.� N)�Any�Callable�Dict�List�Union)�errors)�os�ntc @ sX e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zdd� ZdS )�ErrorHandleraG Context manager for running code that must be cleaned up on failure.
The context manager allows you to register functions that will be called
when an exception (excluding SystemExit) or signal is encountered.
Usage::
handler = ErrorHandler(cleanup1_func, *cleanup1_args, **cleanup1_kwargs)
handler.register(cleanup2_func, *cleanup2_args, **cleanup2_kwargs)
with handler:
do_something()
Or for one cleanup function::
with ErrorHandler(func, args, kwargs):
do_something()
If an exception is raised out of do_something, the cleanup functions will
be called in last in first out order. Then the exception is raised.
Similarly, if a signal is encountered, the cleanup functions are called
followed by the previously received signal handler.
Each registered cleanup function is called exactly once. If a registered
function raises an exception, it is logged and the next function is called.
Signals received while the registered functions are executing are
deferred until they finish.
c O s<