Thank you for clarification. I tried:

*try*:
    self.lock.acquire()
    [... (some code to calculate and change class attributes)]
*finally*:
    self.lock.release()

And I hope, that deals with that problem.

Tom Keffer schrieb am Dienstag, 16. Februar 2021 um 22:45:42 UTC+1:

> Yes, this is a concern if attributes are not read-only. The wiki article 
> on xtypes has a section about this: 
> https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types#subtlety
>
> On Tue, Feb 16, 2021 at 1:26 PM Karen K <[email protected]> wrote:
>
>> Another question: Is it possible that cheetah generator and image 
>> generator call the XType extension in parallel from different threads?
>>
>> If so, I guess, locking would be needed for code that alters class 
>> attributes.
>>
>> Karen K schrieb am Sonntag, 14. Februar 2021 um 21:55:10 UTC+1:
>>
>>> "Mostly the problem is situated between the chair and the screen." I 
>>> should read the documentation more carefully.
>>>
>>> $day and $yesterday need some aggregation. So it is *not possible* to 
>>> write $day.GTS or $yesterday.GTS because the aggregation type is 
>>> missing. Instead it is necessary to write $day.GTS.last or 
>>> $yesterday.GTS.last or something. And then there is a value, even 
>>> without having the values in the database. Providing the get_aggregate() 
>>> function is sufficient.
>>>
>>> And in this extension all the values are based on outTemp, and outTemp 
>>> is included in the database.
>>> Tom Keffer schrieb am Sonntag, 14. Februar 2021 um 19:33:00 UTC+1:
>>>
>>>> To show a value for yesterday, the value would have to be in the 
>>>> database. 
>>>>
>>>> On Sun, Feb 14, 2021 at 10:29 AM Karen K <[email protected]> wrote:
>>>>
>>>>> Oh, so I mixed it up some way. I registered the XType as a service. 
>>>>>
>>>>> Now there are two different classes, and that looks a lot better. The 
>>>>> extension calculates the values and draws a graph. Thank you for your 
>>>>> advice. It saved a lot of time.
>>>>>
>>>>> $current.GTS displays a value now. $day.GTS and $yesterday.GTS do 
>>>>> not. 
>>>>>
>>>>> Tom Keffer schrieb am Samstag, 13. Februar 2021 um 23:37:58 UTC+1:
>>>>>
>>>>>> Good start! 
>>>>>>
>>>>>> I can see a few issues here.
>>>>>>
>>>>>> 1. All xtype extensions must be registered, otherwise the system has 
>>>>>> no way of knowing of their existence. See the section *Registering 
>>>>>> your subclass 
>>>>>> <https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types#registering-your-subclass>*
>>>>>>  for 
>>>>>> how to register your xtype.
>>>>>>
>>>>>> 2. From what I can tell, your extension only returns a value for 
>>>>>> 'GTSdate', never for 'GTS'.
>>>>>>
>>>>>> 3. I don't quite follow the logic of the loop in get_scalar(), but it 
>>>>>> looks like it is trying to keep a running total of something. Just a 
>>>>>> warning: this could be very inefficient because an xtype can potentially 
>>>>>> get called many times in a template. Would it be possible to refactor 
>>>>>> into 
>>>>>> a database query?
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Sat, Feb 13, 2021 at 1:05 PM Karen K <[email protected]> wrote:
>>>>>>
>>>>>>> And the cheetah generator's result is
>>>>>>>
>>>>>>> Karen K schrieb am Samstag, 13. Februar 2021 um 22:04:36 UTC+1:
>>>>>>>
>>>>>>>> test skin index.html.tmpl
>>>>>>>>
>>>>>>>> -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "weewx-development" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>> send an email to [email protected].
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/weewx-development/1f9090b4-308a-4029-9d84-fcfba0229171n%40googlegroups.com
>>>>>>>  
>>>>>>> <https://groups.google.com/d/msgid/weewx-development/1f9090b4-308a-4029-9d84-fcfba0229171n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "weewx-development" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to [email protected].
>>>>>
>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/weewx-development/09de8f6e-1063-492f-8b4b-add16d6d78den%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/weewx-development/09de8f6e-1063-492f-8b4b-add16d6d78den%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "weewx-development" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-development/02644e98-189c-4857-87cb-2780e7653f56n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/weewx-development/02644e98-189c-4857-87cb-2780e7653f56n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/e5dea169-9f8c-4dc1-80d4-2fbd14239a6en%40googlegroups.com.

Reply via email to