Hi Matthew,

I noticed that the amount of memory used by weewx was increasing over 
time.  Keeping an eye on other properties of the weewx process I noticed 
that the number of threads in weewx was increasing.  I added a bit of code 
to attach unique thread names to all of the weewx threads and noticed that 
specifically it was the number of OpenWeatherMap threads.

My system was occasionally throwing two different errors:
  weewx[11771]: engine: Caught WeeWxIOError: Max tries exceeded while 
getting LOOP data
and 
   weewx[11771]: engine: Database OperationalError exception: database is 
locked

This would trigger the engine to shutdown all of the REST threads via the 
StdRESTful shutdown code and then reload the engine:
    def shutDown(self):
        """Shut down any threads"""
        if hasattr(self, 'loop_queue') and hasattr(self, 'loop_thread'):
            StdRESTful.shutDown_thread(self.loop_queue, self.loop_thread)
        if hasattr(self, 'archive_queue') and hasattr(self, 
'archive_thread'):
            StdRESTful.shutDown_thread(self.archive_queue, 
self.archive_thread)

However the OpenWeatherMap code doesn't use those instance names for the 
queue and the thread.  I think the owm.py code needs to be updated as 
follows:

         site_dict['manager_dict'] = weewx.manager.get_manager_dict(
             config_dict['DataBindings'], config_dict['Databases'], 
'wx_binding')
 
-        self.archive_queue = Queue.Queue()
-        self.archive_thread = OpenWeatherMapThread(self.archive_queue, 
**site_dict)
-        self.archive_thread.start()
+        self._queue = Queue.Queue()
+        self._thread = OpenWeatherMapThread(self._queue, **site_dict)
+        self._thread.start()
         self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)
         loginf("Data will be uploaded for %s" % site_dict['station_id'])
 
     def new_archive_record(self, event):
-        self.archive_queue.put(event.record)
+        self._queue.put(event.record)
 

Also, I think this could be updated as well:
-class OpenWeatherMap(weewx.restx.StdRESTful):
+class OpenWeatherMap(weewx.restx.StdRESTbase):

Thanks,
Ken

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to