SigInfoSingle

SigInfoSingle prints a single variable from the current callstack

SigInfoSingle class

class siginfo.siginfoclass.SigInfoSingle(info=True, usr1=True, usr2=False, output=None)[source]

Bases: SiginfoBasic

SigInfo class that only returns a single value

Example

# create signal listener
foo = SigInfoSingle(usr1=True)

# define which variable to print
foo.set_var('i')

# create executeable to send signal to Python script
foo.create_info_script('/usr/local/bin')

# run your regular code
for n in seq(1, 100):
    do_long_task(i=n)

In another terminal window:

# send signal via custom script
/usr/local/bin/siginfo-USR1

# Output:
4
set_var(varname, default=None)[source]

Defines the variable that should be printed

Parameters:
  • varname (str) – Name of variable from stack frame that should be printed

  • default – Backup value to print if varname is not present in local stack frame. Default: None

Return type:

None

create_info_script(path=None, prefix='', overwrite=False)

Create an executable on the file system to send the appropiate signal.

For user convenience, create executable filess in the specified path that can be used to send corresponding signals to the parent’s script.

Parameters:
  • path (str) – path to executable files (default $HOME)

  • prefix (str) – Prefix of the executable file name (default ‘’)

  • overwrite (bool) – Overwrite existing executables (default False)

Return type:

None