Package wtf :: Package opi :: Module daemon :: Class DetachedRunner
[hide private]
[frames] | no frames]

Class DetachedRunner

source code

object --+    
         |    
    Runner --+
             |
            DetachedRunner

Derived runner, which detaches itself from the terminal
Instance Methods [hide private]
 
__init__(self, daemonopi)
Initialization
source code
 
run(self)
Finalize the setup and start the worker
source code
 
_start(self)
Do the start command
source code
tuple
_make_finalizers(self, err_fd, wfd)
Make finalizers
source code
tuple
_setup_detached(self)
Setup the detached main process
source code
 
_stop(self, signals=('TERM'))
Do the stop command
source code
 
_logreopen(self)
Do the logrotate/logreopen command
source code
 
_signal(self, pid, signame)
Send a signal named signame to process pid.
source code
_DeferredStreamSetup
_setup_stream(self, fileno, filename, flags, defer=False)
Setup a stream to point to a particular file
source code

Inherited from Runner (private): _setup_signals

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
bool detached = True
Is the runner detached?
Instance Variables [hide private]

Inherited from Runner (private): _daemonopi

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, daemonopi)
(Constructor)

source code 
Initialization
Parameters:
Overrides: object.__init__

run(self)

source code 
Finalize the setup and start the worker
Parameters:
  • prerun - Optional initializer/finalizer executed before actually starting up. Called in the worker child (if any).
  • parent_cleanup - Optional function which is called in the parent after a main worker child fork happens.
  • child_cleanup - Optional function which is called in the child after a main worker child fork happens.
  • logrotate - Optional log rotation function
Overrides: Runner.run

See Also: Runner.run

_start(self)

source code 

Do the start command

Actually detach the current process from the terminal and start the regular runner.

_make_finalizers(self, err_fd, wfd)

source code 
Make finalizers
Parameters:
Returns: tuple
Three callables, prerun, parent_cleanup and child_cleanup

_setup_detached(self)

source code 
Setup the detached main process
Returns: tuple
The error stream setup object and a logrotator (maybe None). The setup is deferred so more errors go to the caller's shell
Raises:

_stop(self, signals=('TERM'))

source code 
Do the stop command
Parameters:
  • signals (tuple) - List of signals to send (('name', ...))
Raises:
  • AttributeError - A signal name does not exist
  • SignalError - Error sending the signal

_logreopen(self)

source code 

Do the logrotate/logreopen command

This calls _stop with a different signal set.

_signal(self, pid, signame)

source code 
Send a signal named signame to process pid.
Parameters:
  • pid (int) - pid
  • signame (str) - signal name
Raises:
  • AttributeError - The signal name does not exist
  • SignalError - Error sending the signal

_setup_stream(self, fileno, filename, flags, defer=False)

source code 
Setup a stream to point to a particular file
Parameters:
  • fileno (int) - The descriptor number of the target stream
  • filename (str) - The name of the file to attach
  • flags (int) - Flags to be passed to the open(2) call
  • defer (bool) - Actually dupe the file descriptor to fileno?
Returns: _DeferredStreamSetup
A _DeferredStreamSetup object if the setup is deferred, None otherwise
Raises: