Package gavo :: Package rscdef :: Module executing :: Class Execute
[frames] | no frames]

Class Execute

source code

                   object --+            
                            |            
 base.structure.StructureBase --+        
                                |        
                   object --+   |        
                            |   |        
           base.common.Parser --+        
                                |        
base.structure.ParseableStructure --+    
                                    |    
             base.structure.Structure --+
                                        |
                           object --+   |
                                    |   |
       base.macros.ExpansionDelegator --+
                                        |
                                       Execute

a container for calling code.

This is a cron-like functionality. The jobs are run in separate threads, so they need to be thread-safe with respect to the rest of DaCHS. DaCHS serializes calls, though, so that your code should never run twice at the same time.

At least on CPython, you must make sure your code does not block with the GIL held; this is still in the server process. If you do daring things, fork off (note that you must not use any database connections you may have after forking, which means you can't safely use the RD passed in). See the docs on `Element job`_.

Then testing/debugging such code, use ``gavo admin execute rd#id`` to immediately run the jobs.

Nested Classes

Inherited from base.structure.StructureBase: __metaclass__

Instance Methods
 
spawn(self, cliList)
spawns an external command, capturing the output and mailing it to the admin if it failed.
source code
 
spawnPython(self, pythonFile)
spawns a new python interpreter executing pythonFile.
source code
 
completeElement(self, ctx) source code
 
onElementComplete(self) source code
 
clearProperty(self, name) source code
 
getFullId(self) source code
 
getProperty(self, name, default=<Undefined>) source code
 
hasProperty(self, name) source code
 
setProperty(self, name, value) source code

Inherited from base.structure.Structure: __provides__, callCompletedCallbacks, finishElement, validate

Inherited from base.structure.ParseableStructure: __init__, end_, feed, feedFrom, feedObject, getAttribute, iterEvents, start_, value_

Inherited from base.structure.StructureBase: __providedBy__, adopt, breakCircles, change, copy, getAttributes, getCopyableAttributes, getSourcePosition, iterChildren, setPosition

Inherited from base.common.Parser: feedEvent

Inherited from base.macros.ExpansionDelegator: expand

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

Class Methods

Inherited from base.structure.StructureBase: fromStructure

Class Variables
  name_ = 'execute'
a sentinel for all kinds of undefined values.
  attrSeq = [<gavo.base.attrdef.StringListAttribute object>, <ga...
  managedAttrs = {'at': <gavo.base.attrdef.StringListAttribute o...

Inherited from base.structure.Structure: __implemented__

Inherited from base.structure.StructureBase: completedCallbacks

Properties
  rd

Inherited from object: __class__

Method Details

spawn(self, cliList)

source code 

spawns an external command, capturing the output and mailing it to the admin if it failed.

Output is buffered and mailed, so it shouldn't be too large.

This does not raise an exception if it failed (in normal usage, this would cause two mails to be sent). Instead, it returns the returncode of the spawned process; if that's 0, you're ok. But in general, you wouldn't want to check it.

spawnPython(self, pythonFile)

source code 

spawns a new python interpreter executing pythonFile.

pythonFile may be resdir-relative.

completeElement(self, ctx)

source code 
Overrides: base.structure.Structure.completeElement

onElementComplete(self)

source code 
Overrides: base.structure.Structure.onElementComplete

Class Variable Details

attrSeq

Value:
[<gavo.base.attrdef.StringListAttribute object>,
 <gavo.base.attrdef.BooleanAttribute object>,
 <gavo.base.attrdef.IntAttribute object>,
 <gavo.base.parsecontext.IdAttribute object>,
 <gavo.base.complexattrs.StructAttribute object>,
 <gavo.base.complexattrs.PropertyAttribute object>,
 <gavo.rscdef.common.RDAttribute object>,
 <gavo.base.attrdef.UnicodeAttribute object>]

managedAttrs

Value:
{'at': <gavo.base.attrdef.StringListAttribute object>,
 'debug': <gavo.base.attrdef.BooleanAttribute object>,
 'every': <gavo.base.attrdef.IntAttribute object>,
 'id': <gavo.base.parsecontext.IdAttribute object>,
 'job': <gavo.base.complexattrs.StructAttribute object>,
 'properties': <gavo.base.complexattrs.PropertyAttribute object>,
 'property': <gavo.base.complexattrs.PropertyAttribute object>,
 'rd': <gavo.rscdef.common.RDAttribute object>,
...

Property Details

rd

Get Method:
unreachable._getRD(self)