nspyre.misc
Submodules
Package Contents
Classes
Run a function in a new process. |
Functions
|
Initialize system-wide logging to stdout/err and, optionally, a file. |
Attributes
Pint Quantity class. This is provided for backwards compatibility but is not recommended for future use. |
- nspyre.misc.nspyre_init_logger(log_level, log_path=None, log_path_level=None, prefix='', file_size=None, remove_handlers=True)
Initialize system-wide logging to stdout/err and, optionally, a file.
- Parameters:
log_level (int) – Log messages of lower severity than this will not be sent to stdout/err (e.g.
logging.INFO
).log_path (Optional[pathlib.Path]) – If a file, log to that file. If a directory, generate a log file name containing the prefix and date/time, and create a new log file in that directory. If
None
, only log to stdout/err.log_path_level (Optional[int]) – Logging level for the log file. Leave as
None
for same as log_level.prefix (str) – If a directory was specified for log_path, prepend this string to the log file name.
file_size (Optional[int]) – Maximum log file size (bytes). If this size is exceeded, the log file is rotated according to
RotatingFileHandler
(https://docs.python.org/3/library/logging.handlers.html).remove_handlers (bool) – If true, remove any existing log handlers.
- class nspyre.misc.ProcessRunner(kill=True)
Run a function in a new process.
- Parameters:
kill – Whether to kill a previously running process that hasn’t completed.
- run(fun, *args, **kwargs)
Run the provided function in a separate process.
- Parameters:
fun – Function to run.
args – Arguments to pass to fun.
kwargs – Keyword arguments to pass to fun.
- Raises:
RuntimeError – The function from a previous call is still running.
- running()
Return True if the process is running.
- kill()
Kill the process.
- nspyre.misc.Q_
Pint Quantity class. This is provided for backwards compatibility but is not recommended for future use.