The error occurred before I added any try/except/finally. The error has to
do with it trying to read something that has extraneous characters in it,
and exiting because of it. So I wanted to add the error catching
block...but when I do weewx refuses to run, and exits without any comment,
even when weewx.conf has "debug = 2". As I wrote, the error happens about a
couple time a month. I want to trap it so weewx will continue.

On Wed, Apr 16, 2025 at 1:42 AM gjr80 <[email protected]> wrote:

> Sorry, but I can't tell what code you are running other than to take at
> face value what you post. There is nothing wrong with the
> try..except..finally code as you posted it except for the comments.
> Comments aside, the code you posted cannot have caused the error trace you
> posted as the error trace shows the offending line as line 98 but the code
> you posted has the offending code at line 100. Can you post the exact error
> trace and the exact code that caused that error trace.
>
> Gary
> On Wednesday, 16 April 2025 at 16:28:18 UTC+10 [email protected] wrote:
>
>> Of course they're commented out, when I uncomment [any] of them it exits
>> / crashes. I need it to run until I can have someone tell me what's wrong /
>> why the module crashes weewx. Duh.
>>
>>
>> On Wed, Apr 16, 2025 at 12:13 AM gjr80 <[email protected]> wrote:
>>
>>> In the extension.py you posted the try..except..finally is not executed
>>> as each of the try..except..finally lines is commented out.
>>>
>>> Gary
>>>
>>> On Wednesday, 16 April 2025 at 14:31:01 UTC+10 [email protected]
>>> wrote:
>>>
>>>> I read several add'l values in from static files. Every once in a great
>>>> while, one of the files has extraneous character in it and it can't be read
>>>> as a float() and extensions.py crashes weewx. So after reading about
>>>> try/except/finally from several sources, I wanted to put the section where
>>>> it reads the float in a try statement, and if it fails, the exception
>>>> action is to assign a nominal float value for that weewx cycle, and write
>>>> it to the database. However when I put in the try: it immediately causes
>>>> weewx to exit, at all debug levels.
>>>> If you are more knowledgeable on Python 3 than I am, please look at my
>>>> extensions.py attachment and tell me how I need to restructure that code
>>>> block so it will work. Note, I have tried a couple different positions for
>>>> the initial try: block, no success.
>>>> Further note please, that this only applies to the lines where I
>>>> open '/home/pi/cputemp-opi5p.dat' and read the value into degf2 for it to
>>>> store it in 'extraTemp7'. Note further that this code is working for all
>>>> seven parameters being read and placed into the data, however, occasionally
>>>> (about once a week), somehow the system reads in erroneous data (such
>>>> as '94.8\x00' instead of '94.8')  and causes the python to exit.
>>>> I have looked at places where this data is created and cannot find any
>>>> evidence of that invalid value.
>>>>
>>>> Here is the pertinent part of the log at failure time:
>>>> pi@PI4B1:~ $ systemctl status weewx
>>>> ● weewx.service - WeeWX weather system
>>>>      Loaded: loaded (/etc/systemd/system/weewx.service; enabled; vendor
>>>> preset: enabled)
>>>>      Active: failed (Result: exit-code) since Tue 2025-04-15 16:00:16
>>>> CDT; 4h 18min ago
>>>>        Docs: https://weewx.com/docs
>>>>     Process: 268425 ExecStart=/home/weewx/bin/weewxd
>>>> /home/weewx/weewx.conf (code=exited, status=1/FAILURE)
>>>>    Main PID: 268425 (code=exited, status=1/FAILURE)
>>>>         CPU: 4h 37min 25.648s
>>>>
>>>> Apr 15 16:00:16 PI4B1 weewxd[268425]: weewx[268425] CRITICAL __main__:
>>>>     ****
>>>>  self.engine.dispatchEvent(weewx.Event(weewx.NEW_ARCHIVE_RECORD,
>>>> Apr 15 16:00:16 PI4B1 weewxd[268425]: weewx[268425] CRITICAL __main__:
>>>>     ****    File "/home/weewx/bin/weewx/engine.py", line 245, in
>>>> dispatchEvent
>>>> Apr 15 16:00:16 PI4B1 weewxd[268425]: weewx[268425] CRITICAL __main__:
>>>>     ****      callback(event)
>>>> Apr 15 16:00:16 PI4B1 weewxd[268425]: weewx[268425] CRITICAL __main__:
>>>>     ****    File "/home/weewx/bin/user/extensions.py", line 98, in
>>>> new_archive_packet
>>>> Apr 15 16:00:16 PI4B1 weewxd[268425]: weewx[268425] CRITICAL __main__:
>>>>     ****      degf2 = float(float(f.read()))                #this is OPI5P
>>>> Apr 15 16:00:16 PI4B1 weewxd[268425]: weewx[268425] CRITICAL __main__:
>>>>     ****  ValueError: could not convert string to float: '94.8\x00'
>>>> Apr 15 16:00:16 PI4B1 weewxd[268425]: weewx[268425] CRITICAL __main__:
>>>>     ****  Exiting.
>>>> Apr 15 16:00:16 PI4B1 systemd[1]: weewx.service: Main process exited,
>>>> code=exited, status=1/FAILURE
>>>> Apr 15 16:00:16 PI4B1 systemd[1]: weewx.service: Failed with result
>>>> 'exit-code'.
>>>> Apr 15 16:00:16 PI4B1 systemd[1]: weewx.service: Consumed 4h 37min
>>>> 25.648s CPU time.
>>>>
>>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "weewx-user" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/weewx-user/cM4T6W4XjdA/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected].
>>> To view this discussion visit
>>> https://groups.google.com/d/msgid/weewx-user/62c17a5a-d508-4322-8458-c20941a0f45en%40googlegroups.com
>>> <https://groups.google.com/d/msgid/weewx-user/62c17a5a-d508-4322-8458-c20941a0f45en%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "weewx-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/weewx-user/cM4T6W4XjdA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion visit
> https://groups.google.com/d/msgid/weewx-user/d9a3336a-129e-40df-b302-bff44a9eafdan%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-user/d9a3336a-129e-40df-b302-bff44a9eafdan%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/weewx-user/CAB7-S776S8ECPE_2wE%3D46%3DUpVR2-rfrkWqooL_pzhJjcnFEF7Q%40mail.gmail.com.

Reply via email to