Re: [weewx-development] How to exit the service (without crashing the main process of WeeWx)?

2020-02-12 Thread Thomas Keffer
Things like this should really be run in another thread, which then
communicates with the main thread. It's easy to hang, or even crash, the
main thread if it is dependent on a network connection.

For a fairly simple example of how this is done, look at the weewx-nmea-xdr

service. On startup, it sets up a separate thread, then connects it to the
main thread via a queue. The thread blocks on a serial port. When data
comes in, the thread packages it, then sends it down the queue to the main
thread.

You can do something similar using a socket instead of a serial port.

Now that I think about it, take a look around in the forums. Surely someone
has done something close to what you need!

-tk

On Wed, Feb 12, 2020 at 1:42 PM Tarmo  wrote:

> How to exit the service (to try again later) in an exception without
> crashing the main WeeWx process?
>
> Let's say, I want to connect to a host:
>def connect(self):
> try:
> self.hp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> self.hp.connect(self.host, self.port)
> except socket.error as e:
> logerr("Error: connection failed {}".format(e))
> self.hp.close()
>
>
>
> Now, in case of an exception, I would like to return gracefully to the
> main WeeWx thread without crashing it and try on the next archive interval.
>
> --
> 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 weewx-development+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-development/1ed99eeb-426e-4c6a-a4e2-90bc2b6566ea%40googlegroups.com
> 
> .
>

-- 
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 weewx-development+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/CAPq0zEBo7kYfZVr7KYE2zVKH5pgrLteaVtDy5znPS%3DcjRHQP0A%40mail.gmail.com.


[weewx-development] How to exit the service (without crashing the main process of WeeWx)?

2020-02-12 Thread Tarmo
How to exit the service (to try again later) in an exception without 
crashing the main WeeWx process?

Let's say, I want to connect to a host:
   def connect(self):
try:
self.hp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.hp.connect(self.host, self.port)
except socket.error as e:
logerr("Error: connection failed {}".format(e))
self.hp.close()


 
Now, in case of an exception, I would like to return gracefully to the main 
WeeWx thread without crashing it and try on the next archive interval.

-- 
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 weewx-development+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/1ed99eeb-426e-4c6a-a4e2-90bc2b6566ea%40googlegroups.com.


Re: [weewx-development] 4.0.0b11: table archive_day_wind is not created anymore

2020-02-12 Thread Bernhard R.
Hi Tom,

correct, in this case, the error was located in fromt of the screen...

...surprisingly, you managed to solve this type of errors as well :-)

Thanks again,

bernhard :-)

Am Mittwoch, 12. Februar 2020 01:24:45 UTC+1 schrieb Tom Keffer:
>
> That's no different. You've always needed to specify WXDaySummaryManager 
> to get a wind daily summary.
>
> OK, now I feel better that we understand what happened.
>
> -tk
>
> On Tue, Feb 11, 2020 at 11:04 AM Bernhard R.  > wrote:
>
>> Found the culprit:
>>
>> [DataBindings]
>>
>> [[wx_binding]]
>>
>>  #manager = weewx.manager.DaySummaryManager   # does not 
>> recreate 
>> archive_day_wind
>>  manager = weewx.wxmanager.WXDaySummaryManager# *works!* 
>> (archive_day_wind is created)
>>
>> just in case someone else does similar things one day...
>>
>>
>>
>> Am Dienstag, 11. Februar 2020 19:45:25 UTC+1 schrieb Bernhard R.:
>>>
>>> Hi Tom,
>>>
>>> must be some obscure quirks in my weewx.conf.
>>>
>>> I did a lot of other tests, but finally, I used b12 with the unmodified 
>>> b6 conf file (just adapting the version string) and archive_day_wind is 
>>> created and filled again.
>>>
>>> I'll now adapt the configs line by line and repeat the rebuild process 
>>> after each change to find my error, but you are right (of course) it's not 
>>> a regression in b11, it's a stupid user changing things in files he should 
>>> have understood before doing so...
>>>
>>> Anyways, thanks a lot for your help and sorry for wasting your time...
>>>
>>> bernhard :-)
>>>
>>>
>>>
>>> Am Dienstag, 11. Februar 2020 18:42:46 UTC+1 schrieb Tom Keffer:

 Hmm, I'm unable to reproduce this. 

 I created a schema "schema_with_sunshine_time", derived off the wview 
 schema (NB: *not* wview_extended), then created the database. It had 
 archive_day_wind

 Then I dropped and rebuilt the daily summaries. Still has 
 archive_day_wind.

 This is using v4.0.0b12

 -tk

 On Tue, Feb 11, 2020 at 8:57 AM Bernhard R.  wrote:

> Hi Tom,
>
> the --rebuild-daily was done on 4.0.0b11 version and the table 
> archive_day_wind is not recreated.
>
> All others that are usually present are created as they should 
> (including the ones for the custom fields), only wind is missing.
>
> Thanks for your patience,
>
> Bernhard :-)
>
>
>
>
>
> Am Dienstag, 11. Februar 2020 17:46:38 UTC+1 schrieb Tom Keffer:
>>
>> Sorry. I guess I need to rephrase that. Did you do the 
>> --rebuild-daily under the buggy version? Sounds like you did.
>>
>> That would explain the "regression".
>>
>> -tk
>>
>> On Tue, Feb 11, 2020 at 8:43 AM Bernhard R.  
>> wrote:
>>
>>> Hi Tom,
>>>
>>> The answer was ment to be the second last line of my previous 
>>> message:
>>>
>>> > The database was initially created on v.3.9.1 and extended by 2 
>>> columns with wee_database under 4.0.0b6.
>>>
>>> Was this th information you were asking for?
>>>
>>> I'll take a look at the new type of extension in the meantime...
>>>
>>> Thanks a lot,
>>>
>>> Bernhard :-)
>>>
>>> PS: sorry for accidentially answering by email previously...
>>>
>>>
>>>
>>> Am Dienstag, 11. Februar 2020 17:36:52 UTC+1 schrieb Tom Keffer:

 V4.0 introduces a new way to specify a schema, although the old way 
 is still supported.

 The "wview" schema uses the old way. 

 The "wview_extended" schema uses the new way. How to extend it is 
 documented in the new version of the customizing guide. See the 
 section 
 "Adding a new type to the database". 

 You used an old-style addition on the new-style schema 
 wview_extended. That's why it didn't work.

 But, you didn't answer my question. Did you create the new 
 database using V4.0.0b11, or an earlier version, which, perhaps, 
 contained 
 the bug?

 Cheers,

 -tk


 On Tue, Feb 11, 2020 at 8:28 AM Bernhard R.  
 wrote:

> Hi Tom,
>
> I redefined the schema in a user extension (user.sunduration) like 
> this:
> *schema_with_sunshine_time* = schemas.wview.schema + 
> [('sunshine_time', 'REAL')] + [('sunshine_int', 'INTEGER')]
>
> and use this schema in weewx.conf:
> # The schema defines the structure of the database.
> # It is *only* used when the database is created.
> # schema = schemas.wview_extended.schema
> schema = user.sunduration.*schema_with_sunshine_time*
>
> When I now naively try to redefine the extended schema (following 
> the defaults) in my user extension like that

RE: [weewx-development] WeeWx archiving

2020-02-12 Thread clayj
Yeah – that’s exactly it – DST .

 

Thanks to all who responded…..

 

 

 

From: weewx-development@googlegroups.com  
On Behalf Of gjr80
Sent: Tuesday, February 11, 2020 5:06 PM
To: weewx-development 
Subject: Re: [weewx-development] WeeWx archiving

 

Hmm, wouldn't be a daylight saving change to put clocks back in November each 
year would there?

 

Gary


On Wednesday, 12 February 2020 10:31:36 UTC+10, Tom Keffer wrote:

Yes, modulo DST weirdness, you should see 288 counts per day. 

 

Are the high counts consistent? That is, every day?

 

-tk

 

On Tue, Feb 11, 2020 at 1:44 PM  > wrote:

I’ll admit I haven’t dug deep into the code (yet); but, I’m trying to 
understand how weewx processes archive vs loop records and how those eventually 
get aggregated into the “archive_day” tables.

 

I have loop_interval = 2.5 and archive_interval = 300, if that makes any 
difference.

 

Anyway, what I would have expected is to see at MOST 288 (24*12), maybe +/- 1,  
counts in the “archive_day” tables:

 

Instead, I have below – can anyone offer some insight?

 

Thanks!

Clay Jackson

 

MariaDB [weewx]> select dateTime, from_unixtime(dateTime), `count` from 
archive_day_wind where `count` > 12*24;

++-+---+

| dateTime   | from_unixtime(dateTime) | count |

++-+---+

| 1509865200 | 2017-11-05 00:00:00 |   297 |

| 1541314800 | 2018-11-04 00:00:00 |   298 |

| 1572764400 | 2019-11-03 00:00:00 |   294 |

++-+---+

 

MariaDB [weewx]> select avg(`count`) from archive_day_wind;

+--+

| avg(`count`) |

+--+

| 282.1309 |

+--+

 

 

-- 
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 weewx-de...@googlegroups.com  .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/231a01d5e124%247116a780%245343f680%24%40n7qnm.net
 

 .

-- 
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 weewx-development+unsubscr...@googlegroups.com 
 .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/6d6ea11d-eed2-4349-8c5f-6d6ca8ccf4c2%40googlegroups.com
 

 .

-- 
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 weewx-development+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/259401d5e1bd%240e0cdc10%242a269430%24%40n7qnm.net.