From 61e0a5438905f8fe10951dc287ce7066fc9baac1 Mon Sep 17 00:00:00 2001 From: gjr80 Date: Sat, 20 Jan 2018 10:24:53 +1000 Subject: [PATCH] Altered rtgdthread queue managment to fix 100% CPU usage problem v0.3.2. release --- README.md | 14 +++++++------- bin/user/rtgd.py | 12 ++++++++---- changelog | 2 ++ install.py | 6 ++++-- readme.txt | 14 +++++++------- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 0b29f2c..e7650be 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ The *Realtime gauge-data* extension can be installed manually or automatically u 1. Download the latest *Realtime gauge-data* extension from the *Realtime gauge-data* extension [releases page](https://github.com/gjr80/weewx-realtime_gauge-data/releases) into a directory accessible from the weeWX machine. - wget -P $DOWNLOAD_ROOT https://github.com/gjr80/weewx-realtime_gauge-data/releases/download/v0.3.1/rtgd-0.3.1.tar.gz + wget -P $DOWNLOAD_ROOT https://github.com/gjr80/weewx-realtime_gauge-data/releases/download/v0.3.2/rtgd-0.3.2.tar.gz where $DOWNLOAD_ROOT is the path to the directory where the *Realtime gauge-data* extension is to be downloaded. @@ -49,15 +49,15 @@ The *Realtime gauge-data* extension can be installed manually or automatically u 3. Install the *Realtime gauge-data* extension downloaded at step 1 using the *wee_extension* utility: - wee_extension --install=$DOWNLOAD_ROOT/rtgd-0.3.1.tar.gz + wee_extension --install=$DOWNLOAD_ROOT/rtgd-0.3.2.tar.gz This will result in output similar to the following: - Request to install '/var/tmp/rtgd-0.3.1.tar.gz' - Extracting from tar archive /var/tmp/rtgd-0.3.1.tar.gz + Request to install '/var/tmp/rtgd-0.3.2.tar.gz' + Extracting from tar archive /var/tmp/rtgd-0.3.2.tar.gz Saving installer file to /home/weewx/bin/user/installer/Rtgd Saved configuration dictionary. Backup copy at /home/weewx/weewx.conf.20170215124410 - Finished installing extension '/var/tmp/rtgd-0.3.1.tar.gz' + Finished installing extension '/var/tmp/rtgd-0.3.2.tar.gz' 4. Start weeWX: @@ -73,13 +73,13 @@ This will result in the *gauge-data.txt* file being generated on receipt of each 1. Download the latest *Realtime gauge-data* extension from the Realtime gauge-data [releases page](https://github.com/gjr80/weewx-realtime_gauge-data/releases) into a directory accessible from the weeWX machine. - wget -P $DOWNLOAD_ROOT https://github.com/gjr80/weewx-realtime_gauge-data/releases/download/v0.3.1/rtgd-0.3.1.tar.gz + wget -P $DOWNLOAD_ROOT https://github.com/gjr80/weewx-realtime_gauge-data/releases/download/v0.3.2/rtgd-0.3.2.tar.gz where $DOWNLOAD_ROOT is the path to the directory where the *Realtime gauge-data* extension is to be downloaded. 2. Unpack the extension as follows: - tar xvfz rtgd-0.3.1.tar.gz + tar xvfz rtgd-0.3.2.tar.gz 3. Copy files from within the resulting directory as follows: diff --git a/bin/user/rtgd.py b/bin/user/rtgd.py index b366dd9..45530da 100644 --- a/bin/user/rtgd.py +++ b/bin/user/rtgd.py @@ -17,13 +17,15 @@ # You should have received a copy of the GNU General Public License along with # this program. If not, see http://www.gnu.org/licenses/. # -# Version: 0.3.1 Date: 3 December 2017 +# Version: 0.3.2 Date: 20 January 2018 # # Revision History +# 20 January 2018 v0.3.2 +# - modified rtgdthread queue management to fix 100% CPU usage issue # 3 December 2017 v0.3.1 # - added ignore_lost_contact config option to ignore the sensor contact # check result -# - refactored lost contact flag check code, now uses a dedictaed method +# - refactored lost contact flag check code, now uses a dedicated method # to determine whether sensor contact has been lost # - changed a syslog entry to indicate 'rtgd' as the source not 'engine' # 4 September 2017 v0.3.0 @@ -63,7 +65,7 @@ # 'wedge' would occasionally temporarily disappear from wind speed # gauge # 28 February 2017 v0.2.8 -# - Reworked day max/min calculations to better handle missing historical +# - reworked day max/min calculations to better handle missing historical # data. If historical max/min data is missing day max/min will default # to the current value for the obs concerned. # 26 February 2017 v0.2.7 @@ -947,7 +949,9 @@ def run(self): self.forecast_text = _package['payload'] # now deal with the control queue try: - _package = self.control_queue.get_nowait() + # block for one second waiting for package, if nothing + # received throw Queue.Empty + _package = self.control_queue.get(True, 1.0) except Queue.Empty: # nothing in the queue so continue pass diff --git a/changelog b/changelog index 7496b5e..a587108 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,5 @@ +v0.3.2 +* modified rtdgthread queue management to fix 100% CPU usage issue v0.3.1 * added ignore_lost_contact config option to ignore the sensor contact check result diff --git a/install.py b/install.py index 349e5ac..97c7ac6 100644 --- a/install.py +++ b/install.py @@ -11,9 +11,11 @@ # # Installer for Realtime gauge-data # -# Version: 0.3.1 Date: 3 December 2017 +# Version: 0.3.2 Date: 20 January 2018 # # Revision History +# 20 January 2018 v0.3.2 +# - bumped version only # 3 December 2017 v0.3.1 # - bumped version only # 4 September 2017 v0.3.0 @@ -59,7 +61,7 @@ from setup import ExtensionInstaller REQUIRED_VERSION = "3.4.0" -RTGD_VERSION = "0.3.1" +RTGD_VERSION = "0.3.2" def loader(): diff --git a/readme.txt b/readme.txt index 44d814c..673b581 100644 --- a/readme.txt +++ b/readme.txt @@ -43,7 +43,7 @@ gauge-data releases page (https://github.com/gjr80/weewx-realtime_gauge-data a directory accessible from the weeWX machine. wget -P $DOWNLOAD_ROOT https://github.com/gjr80/weewx-realtime_gauge-data -/releases/download/v0.3.1/rtgd-0.3.1.tar.gz +/releases/download/v0.3.2/rtgd-0.3.2.tar.gz where $DOWNLOAD_ROOT is the path to the directory where the Realtime gauge-data extension is to be downloaded. @@ -59,15 +59,15 @@ a directory accessible from the weeWX machine. 3. Install the Realtime gauge-data extension downloaded at step 1 using the wee_extension utility: - wee_extension --install=$DOWNLOAD_ROOT/rtgd-0.3.1.tar.gz + wee_extension --install=$DOWNLOAD_ROOT/rtgd-0.3.2.tar.gz This will result in output similar to the following: - Request to install '/var/tmp/rtgd-0.3.1.tar.gz' - Extracting from tar archive /var/tmp/rtgd-0.3.1.tar.gz + Request to install '/var/tmp/rtgd-0.3.2.tar.gz' + Extracting from tar archive /var/tmp/rtgd-0.3.2.tar.gz Saving installer file to /home/weewx/bin/user/installer/Rtgd Saved configuration dictionary. Backup copy at /home/weewx/weewx.conf.20161123124410 - Finished installing extension '/var/tmp/rtgd-0.3.1.tar.gz' + Finished installing extension '/var/tmp/rtgd-0.3.2.tar.gz' 4. Start weeWX: @@ -91,14 +91,14 @@ gauge-data releases page (https://github.com/gjr80/weewx-realtime_gauge-data a directory accessible from the weeWX machine. wget -P $DOWNLOAD_ROOT https://github.com/gjr80/weewx-realtime_gauge-data -/releases/download/v0.3.1/rtgd-0.3.1.tar.gz +/releases/download/v0.3.2/rtgd-0.3.2.tar.gz where $DOWNLOAD_ROOT is the path to the directory where the Realtime gauge-data extension is to be downloaded. 2. Unpack the extension as follows: - tar xvfz rtgd-0.3.1.tar.gz + tar xvfz rtgd-0.3.2.tar.gz 3. Copy files from within the resulting folder as follows: