Package omero :: Module processor :: Class ProcessI
[hide private]
[frames] | no frames]

Class ProcessI

source code


Wrapper around a subprocess.Popen instance. Returned by ProcessorI when a job is submitted. This implementation uses the given interpreter to call a file that must be named "script" in the generated temporary directory.

Call is equivalent to:

cd TMP_DIR ICE_CONFIG=./config interpreter ./script >out 2>err &

The properties argument is used to generate the ./config file.

The params argument may be null in which case this process is being used solely to calculate the parameters for the script ("omero.scripts.parse=true")

If iskill is True, then on cleanup, this process will reap the attached session completely.

Instance Methods [hide private]
 
__init__(self, ctx, interpreter, properties, params, iskill=False, Popen=subprocess.Popen, callback_cast=omero.grid.ProcessCallbackPrx.uncheckedCast)
Popen and callback_Cast are primarily for testing.
source code
 
make_env(self) source code
 
make_files(self) source code
 
make_config(self)
Creates the ICE_CONFIG file used by the client.
source code
 
tmp_client(self)
Create a client for performing cleanup operations.
source code
 
activate(self)
Process creation has to wait until all external downloads, etc are finished.
source code
 
deactivate(self)
Cleans up the temporary directory used by the process, and terminates the Popen process if running.
source code
 
isActive(self)
Tests only if this instance has a non-None popen attribute.
source code
 
wasActivated(self)
Returns true only if this instance has either a non-null popen or a non-null rcode field.
source code
 
isRunning(self) source code
 
isFinished(self) source code
 
alreadyDone(self)
Allows short-cutting various checks if we already have a rcode for this popen.
source code
 
__del__(self) source code
 
check(self)
Called periodically to keep the session alive.
source code
 
cleanup(self)
Deactivates the process (if active) and cleanups the server connection.
source code
 
cleanup_output(self)
Flush and close the stderr and stdout streams.
source code
 
upload_output(self)
If this is not a params calculation (i.e.
source code
 
_upload(self, upload, client, filename, name, format) source code
 
cleanup_tmpdir(self)
Remove all known files and finally the temporary directory.
source code
 
status(self, msg="") source code
 
poll(self, current=None)
Checks popen.poll() (if active) and notifies all callbacks if necessary.
source code
 
wait(self, current=None)
Waits on popen.wait() to return (if active) and notifies all callbacks.
source code
 
_term(self)
Attempts to cancel the process by sending SIGTERM (or similar)
source code
 
_send(self, iskill)
Helper method for sending signals.
source code
 
cancel(self, current=None)
Tries to cancel popen (if active) and notifies callbacks.
source code
 
kill(self, current=None) source code
 
shutdown(self, current=None)
If self.popen is active, then first call cancel, wait a period of time, and finally call kill.
source code
 
registerCallback(self, callback, current=None) source code
 
unregisterCallback(self, callback, current=None) source code
 
allcallbacks(self, method, arg) source code
 
__str__(self)
str(x)
source code

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

Instance Variables [hide private]
  interpreter
Executable which will be used on the script
  properties
Properties used to create an Ice.Config
  params
JobParams for this script.
  iskill
Whether or not, cleanup should kill the session
  Popen
Function which should be used for creating processes
  callback_cast
Function used to cast all ProcessCallback proxies
  rcode
return code from popen
  callbacks
dictionary from id strings to callback proxies
  popen
process.
  pid
pid of the process.
  started
time the process started
  stopped
time of deactivation
  uuid
session this instance is tied to
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, ctx, interpreter, properties, params, iskill=False, Popen=subprocess.Popen, callback_cast=omero.grid.ProcessCallbackPrx.uncheckedCast)
(Constructor)

source code 

Popen and callback_Cast are primarily for testing.

Overrides: object.__init__

tmp_client(self)

source code 

Create a client for performing cleanup operations. This client should be closed as soon as possible by the process

activate(self)

source code 

Process creation has to wait until all external downloads, etc are finished.

Decorators:
  • @locked

deactivate(self)

source code 

Cleans up the temporary directory used by the process, and terminates the Popen process if running.

Decorators:
  • @locked

isActive(self)

source code 

Tests only if this instance has a non-None popen attribute. After activation this method will return True until the popen itself returns a non-None value (self.rcode) at which time it will be nulled and this method will again return False

Decorators:
  • @locked

wasActivated(self)

source code 

Returns true only if this instance has either a non-null popen or a non-null rcode field.

Decorators:
  • @locked

isRunning(self)

source code 
Decorators:
  • @locked

isFinished(self)

source code 
Decorators:
  • @locked

alreadyDone(self)

source code 

Allows short-cutting various checks if we already have a rcode for this popen. A non-None return value implies that a process was started and returned the given non-None value itself.

Decorators:
  • @locked

check(self)

source code 

Called periodically to keep the session alive. Returns False if this resource can be cleaned up. (Resources API)

Decorators:
  • @perf
  • @locked

cleanup(self)

source code 

Deactivates the process (if active) and cleanups the server connection. (Resources API)

Decorators:
  • @perf
  • @locked

upload_output(self)

source code 

If this is not a params calculation (i.e. parms != null) and the stdout or stderr are non-null, they they will be uploaded and attached to the job.

cleanup_tmpdir(self)

source code 

Remove all known files and finally the temporary directory. If other files exist, an exception will be raised.

poll(self, current=None)

source code 

Checks popen.poll() (if active) and notifies all callbacks if necessary. If this method returns a non-None value, then the process will be marked inactive.

Decorators:
  • @perf
  • @remoted

wait(self, current=None)

source code 

Waits on popen.wait() to return (if active) and notifies all callbacks. Marks this process as inactive.

Decorators:
  • @perf
  • @remoted

_send(self, iskill)

source code 

Helper method for sending signals. This method only makes a call is the process is active.

cancel(self, current=None)

source code 

Tries to cancel popen (if active) and notifies callbacks.

Decorators:
  • @perf
  • @remoted

kill(self, current=None)

source code 
Decorators:
  • @perf
  • @remoted

shutdown(self, current=None)

source code 

If self.popen is active, then first call cancel, wait a period of time, and finally call kill.

Decorators:
  • @perf
  • @remoted

registerCallback(self, callback, current=None)

source code 
Decorators:
  • @remoted
  • @locked

unregisterCallback(self, callback, current=None)

source code 
Decorators:
  • @remoted
  • @locked

allcallbacks(self, method, arg)

source code 
Decorators:
  • @locked

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

Instance Variable Details [hide private]

params

JobParams for this script. Possibly None

popen

process. if None, then this instance isn't alive.

pid

pid of the process. Once set, isn't nulled.