[ews-app] Run BugzillaPatchFetcher periodically
authoraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Dec 2018 19:34:45 +0000 (19:34 +0000)
committeraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Dec 2018 19:34:45 +0000 (19:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192241

Reviewed by Lucas Forschler.

* BuildSlaveSupport/ews-app/ews/__init__.py:
* BuildSlaveSupport/ews-app/ews/apps.py:
(EwsConfig.ready): This method is called by Django on startup.
* BuildSlaveSupport/ews-app/ews/fetcher.py:
(FetchLoop): Class which invokes BugzillaPatchFetcher every 60s.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238865 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/BuildSlaveSupport/ews-app/ews/__init__.py
Tools/BuildSlaveSupport/ews-app/ews/apps.py
Tools/BuildSlaveSupport/ews-app/ews/fetcher.py
Tools/ChangeLog

index 7f9b9ce..fbccd87 100644 (file)
@@ -1,3 +1,5 @@
 import logging
 
 logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(message)s')
+
+default_app_config = 'ews.apps.EwsConfig'
index 5ac6230..fb51472 100644 (file)
@@ -27,3 +27,8 @@ from django.apps import AppConfig
 
 class EwsConfig(AppConfig):
     name = 'ews'
+
+    def ready(self):
+        # FIXME: Ensure that this method is called only once.
+        from ews.fetcher import FetchLoop
+        FetchLoop()
index 5a0037b..2c35ded 100644 (file)
@@ -21,6 +21,8 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import logging
+import threading
+import time
 
 from ews.common.bugzilla import Bugzilla
 from ews.common.buildbot import Buildbot
@@ -29,6 +31,19 @@ from ews.models.patch import Patch
 _log = logging.getLogger(__name__)
 
 
+class FetchLoop():
+    def __init__(self, interval=60):
+        self.interval = interval
+        thread = threading.Thread(target=self.run, args=())
+        thread.daemon = True
+        thread.start()
+
+    def run(self):
+        while True:
+            BugzillaPatchFetcher().fetch()
+            time.sleep(self.interval)
+
+
 class BugzillaPatchFetcher():
     def fetch(self):
         patch_ids = Bugzilla.get_list_of_patches_needing_reviews()
index 6aecd23..94b9bb1 100644 (file)
@@ -1,3 +1,16 @@
+2018-12-04  Aakash Jain  <aakash_jain@apple.com>
+
+        [ews-app] Run BugzillaPatchFetcher periodically
+        https://bugs.webkit.org/show_bug.cgi?id=192241
+
+        Reviewed by Lucas Forschler.
+
+        * BuildSlaveSupport/ews-app/ews/__init__.py:
+        * BuildSlaveSupport/ews-app/ews/apps.py:
+        (EwsConfig.ready): This method is called by Django on startup.
+        * BuildSlaveSupport/ews-app/ews/fetcher.py:
+        (FetchLoop): Class which invokes BugzillaPatchFetcher every 60s.
+
 2018-12-04  Jonathan Bedard  <jbedard@apple.com>
 
         webkitpy: Support unicode in MeteredStream