shell_pool - Shell Pooling Manager

Module defining the shell pool class.

The shell pool is used by the test run state machine to control the shells spawned by the test suites. Each layer of execution can stash the current pool and create a new layer of shells by calling start_new_pool. You can go back to the previous pool by calling terminate_current_pool. These layers are identified in the pool as levels where the higher the number, the deeper the layer of execution. As an example layers of execution could be: test run, test suite and test case. Which could appropriately identified with level numbers 0, 1 and 2 respectively.

The shell pool layers are implemented as a stack. Therefore, when creating a new pool, this is pushed on top of the stack. Similarly, terminating the current pool also means removing the one at the top of the stack.

class ShellPool

Bases: object

A pool managing active shells.

__init__()

Shell pool constructor.

property pool_level: int

The current level of shell pool.

The higher level, the deeper we are in the execution state.

register_shell(shell: InteractiveShell)

Register a new shell to the current pool.

unregister_shell(shell: InteractiveShell)

Unregister a shell from any pool.

start_new_pool()

Start a new shell pool.

terminate_current_pool()

Terminate all the shells in the current pool, and restore the previous pool if any.

If any failure occurs while closing any shell, this is tolerated allowing the termination to continue until the current pool is empty and removed. But this function will re-raise the last occurred exception back to the caller.