[GE users] Problem running load sensor in python

juby justin.ottley at gmail.com
Tue Mar 17 17:28:52 GMT 2009


Hey,

as an alternative, you can do it all in python if you want. Im using a 
sensor that looks like this (i too use the unbuffered flag, but im not 
100% sure if its necessary):

#!/usr/bin/env python -u

while True:
    stdin = raw_input()
    if stdin == "quit":
        sys.exit()
    if stdin == '':
        print 'begin'
        print 'cviant39.cv.hp.com:mem_free_s:1.2G'
        print 'end'


sumyee wrote:
> My Python script is actually called by a shell script.  The shell script is written as follows:
>
>
> #!/bin/bash
>
> while [ 1 ]; do
> 	read "input"
> 	result=$?
> 	if [ $result != 0 ]; then
> 		Exit 1
> 	fi
>
> 	if [ "$input" = "quit" ]; then
> 		exit 0
> 	fi
>
> 	echo begin
> 	python -u /usr/local/GridEngine/custom/src/load_sensor/load.py
> 	echo end
> done
>
> exit 0
>
> -----------------------------------------------------------------------------------------------------
>
> The strange thing to me is that when I replace the python command with a perl command, everything works as expected.  
>
> I have already unbufferred the python I/O stream with the -u flag, but that didn't help. 
>
> Thanks!
>
> Sum Yee
> X50848
>
>
> -----Original Message-----
> From: Dan.Templeton at Sun.COM [mailto:Dan.Templeton at Sun.COM] 
> Sent: Tuesday, March 17, 2009 8:58 AM
> To: users at gridengine.sunsource.net
> Subject: Re: [GE users] Problem running load sensor in python
>
> The script you included does not print "begin" or "end."  Also, aside 
> from waiting to end until is gets a "quit," the script should wait to 
> output its values until asked for them.
>
> Daniel
>
> rayson wrote:
>   
>> 1) First thing, shouldn't a load sensor loop until it receives "quit" by SGE??
>>
>> Like this: http://gridengine.sunsource.net/howto/loadsensor.html
>>
>>
>> 2) I'm not very good at Python, but if you are sure that the
>> equivalent scipt written in bash or Perl works, then you can try to
>> unbuffer the Python I/O stream:
>>
>> http://stackoverflow.com/questions/107705/python-output-buffering
>>
>> Rayson
>>
>>
>>
>> On 3/17/09, sumyee <sum-yee.lai at hp.com> wrote:
>>   
>>     
>>> Hello,
>>>
>>> I am running SGE6.2, and I have a problem with running a load sensor written in python.  The values written out by the load sensor doesn't seem to get "picked up" by SGE.  The python script echoes the following when I run it manually:
>>>
>>> begin
>>> cviant39.cv.hp.com:mem_free_s:1.2G
>>> cviant39.cv.hp.com:mem_free_h:1.5G
>>> end
>>>
>>> Running qhost -F on cviant39 gives me:
>>>   hf:mem_free_h=1.915G
>>>   hf:mem_free_s=1.915G
>>>
>>>
>>> Instead of using the mem_free_s and mem_free_h values printed out by the python script, Grid uses the maximum values set on the host.  When I run the same statements in bash or perl, Grid seems to pick up the values without problem.  Has anyone seen this problem before?
>>>
>>> My python script (that doesn't work) is very simple:
>>>
>>> #!/usr/bin/env python
>>>
>>> import os
>>>
>>> hostname = str(os.environ.get('HOSTNAME'))
>>> print hostname + ":mem_free_s:1.2G"
>>> print hostname + ":mem_free_h:1.5G"
>>>
>>>
>>> Sum Yee Lai
>>>
>>> ------------------------------------------------------
>>> http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=134375
>>>
>>> To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].
>>>
>>>     
>>>       
>> ------------------------------------------------------
>> http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=134407
>>
>> To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].
>>
>>     
>
> ------------------------------------------------------
> http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=134408
>
> To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].
>
> ------------------------------------------------------
> http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=134451
>
> To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].
>
>
>

------------------------------------------------------
http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=134477

To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].



More information about the gridengine-users mailing list