Background green threads for notifications!

General Discussion

Background green threads for notifications!

Postby mathewss » Wed Jul 31, 2019 11:18 pm

I was finding many problems with slow lagging notifications to some devices due to the time in sending emails or Twilio messages.

This refactor of the notifications code in the webapp will ensure all notifications that have slow IO intensive process run in parallel.

This will add a small delay to each delivery but prevent stalling out of the web interface or other notifications due to one notification that is slow.

It will require me to make a new image or if you want the feature to manually add a new package. AFAIK this will not cause any issues with future porting to Python 3.

sudo apt-get install python-concurrent.futures


[2019-07-31 23:52:57 +0000] [28653] [INFO] Starting gunicorn 19.9.0
[2019-07-31 23:52:57 +0000] [28653] [DEBUG] Arbiter booted
[2019-07-31 23:52:57 +0000] [28653] [INFO] Listening at: http://127.0.0.1:8000 (28653)
[2019-07-31 23:52:57 +0000] [28653] [INFO] Using worker: socketio.sgunicorn.GeventSocketIOWorker
[2019-07-31 23:52:57 +0000] [28657] [INFO] Booting worker with pid: 28657
[2019-07-31 23:52:57 +0000] [28653] [DEBUG] 1 workers
[2019-07-31 23:53:07,108] INFO in decoder: AlarmDecoder Webapp booting up - v0.8.3-35-g34ee934
[2019-07-31 23:53:07,134] DEBUG in decoder: Database is good!
[2019-07-31 23:53:07,167] INFO in types: Library concurrent.futures.ThreadPoolExecutor found and loaded.
[2019-07-31 23:53:07,175] INFO in types: ThreadPoolExecutor enabled for notifications with max_workders 5.

[2019-07-31 23:56:32,140] INFO in types: Background notification function MatrixNotification._do_post() starting.
[2019-07-31 23:56:32,146] INFO in types: Event: The alarm system has been armed STAY.
[2019-07-31 23:56:32,177] INFO in types: Background notification function UPNPPushNotification._send_notify_event() starting.
[2019-07-31 23:56:32,434] INFO in types: Background notification functions running 10.
[2019-07-31 23:56:32,436] INFO in types: Background notification function UPNPPushNotification._send_notify_event() finished with no exceptions.
[2019-07-31 23:56:32,437] INFO in types: Background notification function UPNPPushNotification._send_notify_event() finished with no exceptions.
[2019-07-31 23:56:32,439] INFO in types: Background notification function EmailNotification._send() finished with no exceptions.
[2019-07-31 23:56:32,441] INFO in types: Background notification function MatrixNotification._do_post() finished with no exceptions.
[2019-07-31 23:56:32,443] INFO in types: Background notification function UPNPPushNotification._send_notify_event() finished with no exceptions.
[2019-07-31 23:56:32,444] INFO in types: Background notification function UPNPPushNotification._send_notify_event() finished with no exceptions.
[2019-07-31 23:56:32,446] INFO in types: Background notification function UPNPPushNotification._send_notify_event() finished with no exceptions.
[2019-07-31 23:56:37,449] INFO in types: Background notification functions running 3.
[2019-07-31 23:56:37,451] INFO in types: Background notification function EmailNotification._send() finished with no exceptions.
[2019-07-31 23:56:37,457] INFO in types: Background notification function MatrixNotification._do_post() finished with no exceptions.
[2019-07-31 23:56:37,459] INFO in types: Background notification function UPNPPushNotification._send_notify_event() finished with no exceptions.

127.0.0.1 - - [2019-07-31 23:56:38] "GET /log/alarmdecoder/get_data/25 HTTP/1.1" 200 5501 0.022021
[2019-07-31 23:56:47,662] INFO in types: Event: 0014374:0:0:1:1:0:0
[2019-07-31 23:56:47,694] INFO in types: Background notification function UPNPPushNotification._send_notify_event() starting.
127.0.0.1 - - [2019-07-31 23:56:48] "GET /log/alarmdecoder/get_data/25 HTTP/1.1" 200 5349 0.022845
[2019-07-31 23:56:49,532] INFO in types: Event: 0014374:0:0:0:1:0:0
[2019-07-31 23:56:49,563] INFO in types: Background notification function UPNPPushNotification._send_notify_event() starting.
[2019-07-31 23:56:52,464] INFO in types: Background notification functions running 2.
mathewss
Moderator
Moderator
 
Posts: 188
Joined: Fri Dec 06, 2013 11:14 am

Return to General

Who is online

Users browsing this forum: No registered users and 7 guests

cron