[AG-TECH] GetData() problem in wxPython shared application
Thomas D. Uram
turam at mcs.anl.gov
Wed Apr 13 08:43:04 CDT 2005
First, a note: if a non-existent key is passed to GetData, an empty string is returned.
This causes variation in the evaluations that you did (len(d)>0 is false; d!=0 and d!=None
are true). You might instead simply use 'if d:'. Initialization should not have any
effect. I'm curious about the junk you got back.
As to your question: The application session in the venue doesn't clear out data when the
last client leaves and, currently at least, can't be made to do so without some server
side modifications. A client could check to see if it is the last or first to join (using
the GetParticipants call) and zero out the data; not exactly a great solution, but one
that would work. Also, there is not currently a method for removing data, so you can only
zero it out.
Tom
Stephen Jeffrey wrote:
> Thanks Susanne. If I initialise the variable before
> calling GetData(), and then test using
>
> if self.file:
>
> it seems to work OK.
>
> I now have another problem - the data does not get deleted
> from the application service when all copies of the application
> are terminated. The very first time the application is started,
> it reports there is no data stored, as it should. However if
> I terminate the application and then restart it, it reports
> that there is existing data. The only way to delete the data
> appears to be to delete the shared app from the venue client
> window, and then add the shared app again (using the Start
> Application Session option under the Venue menu in the venue
> client window). Is this normal behaviour, or do I have to
> somehow manually delete the data when the application terminates?
>
> cheers
> steve
>
>
> Susanne Lefvert wrote:
>
>> This works for me:
>>
>> -----------------------
>> self.file = None
>>
>> # Get current state
>> self.file = self.sharedAppClient.GetData("file")
>>
>> if self.file:
>> # do stuff
>> else:
>> print "data does not exist..."
>> ------------------------
>>
>> Which platform?
>>
>> Susanne
>>
>>
>> On Wed, 13 Apr 2005, Stephen Jeffrey wrote:
>>
>>
>>> Hi All,
>>>
>>> I am writing a shared application using wxPython. The application
>>> is to query if there is any shared data present when it starts.
>>> ie. if another copy of the application is already running and has
>>> sent some data using sharedAppClient.SetData(), when the second
>>> copy of the application starts it should obtain the data stored
>>> by the first copy.
>>>
>>> How can I query if there is any shared data already present?
>>> I have tried:
>>>
>>> d = self.sharedAppClient.GetData("data")
>>> if len(d) > 0:
>>>
>>> and other variations such as:
>>>
>>> d = self.sharedAppClient.GetData("data")
>>> if d != 0:
>>>
>>> and
>>>
>>> d = self.sharedAppClient.GetData("data")
>>> if d != None:
>>>
>>> but it appears as though GetData() is returning junk - when the
>>> first copy of the application starts there should not be
>>> any shared data present, but it returns non-zero data.
>>>
>>> Is there some way to overcome this, or do I have to somehow
>>> get the first instance of the application to "initialise"
>>> the shared data.
>>>
>>> cheers
>>> steve
>>>
>>> --
>>> Dr Stephen Jeffrey
>>> Advanced Computational Modelling Centre
>>> University of Queensland
>>> St. Lucia Queensland 4072 Australia
>>>
>>> Phone: +61 (7) 3365 6130
>>> Fax: +61 (7) 3365 6136
>>> Email: sjj at maths.uq.edu.au
>>> Web: http://www.acmc.uq.edu.au
>>>
>>>
>
>
More information about the ag-tech
mailing list