Rajat,
I did implement what Charles Rankin suggested, i.e. leverage the
Queue, which is associated with each STAF handle. The Jython/Python
script periodically check it's STAF queue to see if there are any
"commands" on it - if so it executes them and sends back the result to
whomever placed the command on its queue. See attached proof of
concept.
-Jesse
On Fri, Jan 23, 2009 at 1:31 AM, <dudeja.ra...@gmail.com> wrote:
> Dear Jesse,
>
> I saw one of your post on STAF User mailing list where you cracked a very
> interesting problem "Connect to a remote interpreter".
>
> I'm facing the same problem so thought of writing to you. I'ld appreciate if
> you can share the solution.
>
> I've this requirement that at the start of my XML job I want to start a
> Python interpreter and keep it for the course of this test case and during
> this time I want to run several python scripts on this interpreter. I've
> the requirement to run this both locally and remotely.
>
> Appreciate your help in this matter.
>
>
> Cheers,
> Rajat
# QUEUE approach implemented in Jython
# Jesse Millan, 2-15-2007
#
# Example usage:
# ./jython script ~/POC.py
# staf local QUEUE QUEUE HANDLE 187 MESSAGE "abs(-13)" TYPE 0
# staf local queue list handle 187
# staf local QUEUE QUEUE HANDLE 187 MESSAGE "exit()" TYPE 0
import com.ibm.staf
global COMMAND, RESPONSE, returnVal
COMMAND=0
RESPONSE=1
exitTime=0
handle = com.ibm.staf.STAFHandle("POC")
print "Send commands to handle: " + str(handle.getHandle())
while 1:
queueResult = handle.submit2("local", "QUEUE", "GET TYPE " +
str(COMMAND) + " WAIT")
message = com.ibm.staf.STAFQueueMessage(queueResult.result)
print "executing the command: " + str(message.message)
exec("returnVal=" + str(message.message))
handle.submit2("local", "QUEUE", "QUEUE HANDLE " +
str(handle.getHandle()) + " TYPE response MESSAGE " + "return value: " +
str(returnVal))
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users