asyncutils.config¶
Set up some module-global state and sentinels, and expose some user-specified flags.
Attributes¶
Whether the user specified not to use the functions from |
|
A global instance of the |
|
Whether all submodules of this module have been loaded. |
|
The name of (i.e. possibly relative path to) the log file currently used by this library as a string, with four exceptions: |
|
Maximum number of memory errors that can occur before the console automatically exits. Negative iff there is no maximum. |
|
Whether the user specified to drop into the debugger on an unhandled exception in the REPL console. |
|
Whether the user requested to run the program with no banner and exit message in the REPL. |
Exceptions¶
Raised when the user specifies a configuration value that is of the wrong type or otherwise invalid. This is basically impossible to catch, since it is only raised during the import of this module. |
Classes¶
A context manager used to enter and exit debug mode, ensuring restoration of the original level if the level has not been modified externally within the context using |
|
A class that implements the PEP 3148 executor interface. |
Functions¶
|
Return all stored logs as a string. Logs are stored iff |
|
Set the level of the module-global logger to |
Module Contents¶
- exception asyncutils.config.FaultyConfig(key: str, wrong: str, correct: tuple[str, Ellipsis], /)[source]¶
- exception asyncutils.config.FaultyConfig(key: str, wrong: T, correct: R, /)
Bases:
BaseExceptionRaised when the user specifies a configuration value that is of the wrong type or otherwise invalid. This is basically impossible to catch, since it is only raised during the import of this module.
Initialize self. See help(type(self)) for accurate signature.
- class asyncutils.config.Debugging[source]¶
A context manager used to enter and exit debug mode, ensuring restoration of the original level if the level has not been modified externally within the context using
set_logger_level().- __enter__() Self[source]¶
Start debugging. More output is produced; where to depends on the user’s own configuration, accessible via
logging_toanddebug.level.
- __exit__(exc_typ: asyncutils._internal.prots.ExcType, exc_val: BaseException, exc_tb: types.TracebackType, /) None[source]¶
- __exit__(exc_typ: None, exc_val: None, exc_tb: None, /) None
Stop debugging, restoring the output to its previous level if appropriate.
- property level: int¶
The current level of the
asyncutilslogger, as an integer.
- class asyncutils.config.Executor¶
Bases:
concurrent.futures.Executor,asyncutils._internal.prots.PartialInterfaceA class that implements the PEP 3148 executor interface.
Note
The exact class is determined at runtime by command-line arguments.
Tip
Since instances of this class are only ever passed into
run_in_executor(), nothing stops you from monkey-patching the event loop itself or policy thereof, and using a custom class that does not follow the interface, but that may be too hacky and fragile.Tip
If you know your application only uses a specific executor, import this symbol at runtime and import the actual class in the stub or in an
if TYPE_CHECKING:block where applicable to help type checkers.
- asyncutils.config.get_past_logs() str¶
Return all stored logs as a string. Logs are stored iff
asyncutilswas started with-l MEMORY, otherwise an empty string is returned.
- asyncutils.config.set_logger_level(level: int) None¶
Set the level of the module-global logger to
level.
- asyncutils.config.basic_repl: Final[bool]¶
Whether the user specified not to use the functions from
_pyreplto run the console, or they are on a Python version such that_pyreplis not present or cannot be found such that the basic REPL must be used.Deprecated since version 1.1.0: Will be removed when Python 3.12 support is dropped.
- asyncutils.config.debug: Final[Debugging]¶
A global instance of the
Debuggingcontext manager. Initially entered iff the user specified-dor--debugwhen starting the program.
- asyncutils.config.logging_to: Final[str]¶
The name of (i.e. possibly relative path to) the log file currently used by this library as a string, with four exceptions:
'NULL': no logging is taking place'MEMORY': the logs are not going to a physical file but can be retrieved byget_past_logs()'STDOUT': logging is going tosys.stdout'STDERR': logging is going tosys.stderr(following the default and fallback behaviour oflogging)
- asyncutils.config.max_memory_errors: Final[int]¶
Maximum number of memory errors that can occur before the console automatically exits. Negative iff there is no maximum.