Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feeds are not updating #10

Closed
herndlm opened this issue Aug 22, 2021 · 5 comments
Closed

Feeds are not updating #10

herndlm opened this issue Aug 22, 2021 · 5 comments

Comments

@herndlm
Copy link
Contributor

herndlm commented Aug 22, 2021

Hi,

I think there might be a problem with your hosted instance as it seems to be not updating the feeds.

Output of feeds

https://warnung.bund.de/bbk.biwapp/warnmeldungen.json (zuletzt aktualisiert: Mon, 16 Aug 2021 08:07:52 GMT)
https://warnung.bund.de/bbk.mowas/gefahrendurchsagen.json (zuletzt aktualisiert: Mon, 16 Aug 2021 22:33:00 GMT)
https://warnung.bund.de/bbk.lhp/hochwassermeldungen.json (zuletzt aktualisiert: Mon, 16 Aug 2021 22:25:12 GMT)
https://warnung.bund.de/bbk.dwd/unwetter.json (zuletzt aktualisiert: Mon, 16 Aug 2021 22:31:29 GMT)
https://warnung.bund.de/bbk.katwarn/warnmeldungen.json (zuletzt aktualisiert: Mon, 16 Aug 2021 21:21:54 GMT)

I guess you're basically not supporting that instance but I wanted to report this, as it seems to be more global, before trying to host my own.

Btw. I think this project is a great idea and appreciate it very much!

@herndlm herndlm changed the title Hosted instance's feeds are not updating Feeds are not updating Aug 22, 2021
@herndlm
Copy link
Contributor Author

herndlm commented Aug 22, 2021

Fyi I started debugging this, might be related or not but there is definitely a problem in case the async job throws an exception, e.g.

  • start application, see feeds updating every x seconds
  • cause an exception by disabling the network connection
  • reconnect the network
  • see feeds not updating anymore because the task was killed with a CancelledError

I'm not a python dev, but am happy to help out here and learn a thing or the other potentially. Feel free to improve/fix this if you know what's going on, if not or you're busy, I'll try too :)

UPDATE: I might have not been waiting long enough, my use case actually throws an httpx.ConnectError exception after a while that takes down the whole application which is something different hmm. I guess you'll see what's going on when inspecting logs..

@jplitza
Copy link
Owner

jplitza commented Aug 22, 2021

Damn, I hoped you had a lead on this. 😅
I noticed this behavior some weeks ago, but still have to set up proper logging to debug it.

@herndlm
Copy link
Contributor Author

herndlm commented Aug 22, 2021

Well I started running/using it on my raspberry pi now, so I'll take a close look there too

@herndlm
Copy link
Contributor Author

herndlm commented Aug 22, 2021

Oh this is interesting. I can reproduce it at least. It just randomly stops as in

DEBUG:NinaXMPP
:Finished updating feeds, sleeping for 10s
INFO:NinaXMPP:
Updating feed https://warnung.bund.de/bbk.biwapp/warnmeldung
en.json (last modified: Sun, 22 Aug 2021 09:37:43 GMT)
INFO:NinaXMPP:
Updating feed https://warnung.bund.de/bbk.mowas/gefahrendurc
hsagen.json (last modified: Sun, 22 Aug 2021 12:03:44 GMT)
INFO:NinaXMPP:
Updating feed https://warnung.bund.de/bbk.lhp/hochwassermeld
ungen.json (last modified: Sun, 22 Aug 2021 13:10:13 GMT)
INFO:NinaXMPP:
Updating feed https://warnung.bund.de/bbk.dwd/unwetter.json
(last modified: Sun, 22 Aug 2021 13:18:48 GMT)
.. not doing anything anymore

I don't know enough about Python, the libs and the app yet but I wonder if it is dead-locking the DB or something similar. After a restart it immediately imported events. Will continue later..

Actually every or every other new unwetter update seems to lock it again 🤔

herndlm added a commit to herndlm/nina_xmpp that referenced this issue Aug 22, 2021
This seems to be fixing jplitza#10
@herndlm
Copy link
Contributor Author

herndlm commented Aug 22, 2021

I have found at least the problem that disguises the actual problem.

Apparently if there is a reference to a task and the task is not finished yet (because of the SIGINT loop) it will not be garbage collected and this seems to be not triggering its error handling => if any exception is raised inside the task we will never see it unless we kill the app / task. https://bugs.python.org/issue28274 is related
I can verify this by raising any exception in the task which will never be shown except I manually send SIGINT to the process or CTRL-C it.

So I assume some HTTP or parse error is happening but we just don't see it because of the SIGINT loop.

I suggest to improve this first, by failing early if the task fails, e.g. by either using https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.add_done_callback or refactoring the SIGINT loop somehow. I can at least try to improve it :)

After that the actual update feeds task should be hardened by e.g. logging an error and skipping a feed instead of raising an exception that ends the task.

herndlm added a commit to herndlm/nina_xmpp that referenced this issue Aug 22, 2021
- fully switches to the recommended high-level API by not interfering with the loop in any way
- removes the need to manually cleanup tasks by having to wait for a signal
- fixes the problem with the update feeds task where exceptions where only shown on shutdown

This is the first part of the fix for jplitza#10
herndlm added a commit to herndlm/nina_xmpp that referenced this issue Aug 22, 2021
- fully switches to the recommended high-level API by not interfering with the loop in any way
- removes the need to manually cleanup tasks by having to wait for a signal
- fixes the problem with the update feeds task where exceptions where only shown on shutdown

This is the first part of the fix for jplitza#10
herndlm added a commit to herndlm/nina_xmpp that referenced this issue Aug 22, 2021
This logs all request errors via httpx that can happen from time to time (connect error, timeout, ..) and continues updating other feeds instead of terminating the task.
See also https://www.python-httpx.org/exceptions/

This should greatly improve stability of the update feeds task which is related to jplitza#10
jplitza pushed a commit that referenced this issue Aug 31, 2021
This logs all request errors via httpx that can happen from time to time (connect error, timeout, ..) and continues updating other feeds instead of terminating the task.
See also https://www.python-httpx.org/exceptions/

This should greatly improve stability of the update feeds task which is related to #10
@jplitza jplitza closed this as completed Aug 31, 2021
jplitza pushed a commit that referenced this issue Aug 31, 2021
- fully switches to the recommended high-level API by not interfering with the loop in any way
- removes the need to manually cleanup tasks by having to wait for a signal
- fixes the problem with the update feeds task where exceptions where only shown on shutdown

This is the first part of the fix for #10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants