{"action":"created","comment":{"url":"https://api.github.com/repos/StackStorm/st2/pulls/comments/232095620","pull_request_review_id":173216470,"id":232095620,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjA5NTYyMA==","diff_hunk":"@@ -0,0 +1,163 @@\n+# Licensed to the StackStorm, Inc ('StackStorm') under one or more\n+# contributor license agreements.  See the NOTICE file distributed with\n+# this work for additional information regarding copyright ownership.\n+# The ASF licenses this file to You under the Apache License, Version 2.0\n+# (the \"License\"); you may not use this file except in compliance with\n+# the License.  You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+from __future__ import absolute_import\n+import eventlet\n+\n+from st2common import log as logging\n+from st2common.util import date\n+from st2common.constants import action as action_constants\n+from st2common.exceptions.db import StackStormDBObjectNotFoundError\n+from st2common.models.db.liveaction import LiveActionDB\n+from st2common.services import action as action_service\n+from st2common.services import policies as policy_service\n+from st2common.persistence.liveaction import LiveAction\n+from st2common.persistence.execution_queue import ExecutionQueue\n+from st2common.util import action_db as action_utils\n+from st2common.services.coordination import LockAcquireError\n+from st2common.services import coordination\n+\n+__all__ = [\n+    'ExecutionQueueHandler',\n+    'get_handler'\n+]\n+\n+\n+LOG = logging.getLogger(__name__)\n+\n+\n+def _next_executions():\n+    \"\"\"\n+        Sort executions by fifo and priority and get the latest, highest priority\n+        item from the queue and pop it off.\n+    \"\"\"\n+    query = {\n+        \"scheduled_start_timestamp__lte\": date.get_datetime_utc_now(),\n+        \"order_by\": [\n+            \"scheduled_start_timestamp\",\n+        ]\n+    }\n+\n+    queued_executions = ExecutionQueue.query(**query)\n+    if queued_executions:\n+        return queued_executions\n+\n+    return []\n+\n+\n+class ExecutionQueueHandler(object):\n+    def __init__(self):\n+        self.message_type = LiveActionDB\n+        self._shutdown = False\n+\n+    def loop(self):\n+        LOG.debug('Entering scheduler loop')\n+        while self._shutdown is not True:\n+            eventlet.greenthread.sleep(0.25)","path":"st2actions/st2actions/scheduler/handler.py","position":68,"original_position":68,"commit_id":"e713fd80940bba2b001c58e1f42a20ffd707c6d2","original_commit_id":"354d7aef95a45f63788d45af0486f29e37b8e147","user":{"login":"m4dcoder","id":2767408,"node_id":"MDQ6VXNlcjI3Njc0MDg=","avatar_url":"https://avatars2.githubusercontent.com/u/2767408?v=4","gravatar_id":"","url":"https://api.github.com/users/m4dcoder","html_url":"https://github.com/m4dcoder","followers_url":"https://api.github.com/users/m4dcoder/followers","following_url":"https://api.github.com/users/m4dcoder/following{/other_user}","gists_url":"https://api.github.com/users/m4dcoder/gists{/gist_id}","starred_url":"https://api.github.com/users/m4dcoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m4dcoder/subscriptions","organizations_url":"https://api.github.com/users/m4dcoder/orgs","repos_url":"https://api.github.com/users/m4dcoder/repos","events_url":"https://api.github.com/users/m4dcoder/events{/privacy}","received_events_url":"https://api.github.com/users/m4dcoder/received_events","type":"User","site_admin":false},"body":"Since all executions is pushed to the table, I would decrease the value to 0.1 here.  We don't want to hit users with unnecessary latency when there is no delays defined.","created_at":"2018-11-08T23:16:55Z","updated_at":"2018-11-08T23:16:55Z","html_url":"https://github.com/StackStorm/st2/pull/4397#discussion_r232095620","pull_request_url":"https://api.github.com/repos/StackStorm/st2/pulls/4397","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/StackStorm/st2/pulls/comments/232095620"},"html":{"href":"https://github.com/StackStorm/st2/pull/4397#discussion_r232095620"},"pull_request":{"href":"https://api.github.com/repos/StackStorm/st2/pulls/4397"}},"in_reply_to_id":231662947},"pull_request":{"url":"https://api.github.com/repos/StackStorm/st2/pulls/4397","id":223648407,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzNjQ4NDA3","html_url":"https://github.com/StackStorm/st2/pull/4397","diff_url":"https://github.com/StackStorm/st2/pull/4397.diff","patch_url":"https://github.com/StackStorm/st2/pull/4397.patch","issue_url":"https://api.github.com/repos/StackStorm/st2/issues/4397","number":4397,"state":"open","locked":false,"title":"[WIP] Adding delay for task scheduling","user":{"login":"bigmstone","id":4266996,"node_id":"MDQ6VXNlcjQyNjY5OTY=","avatar_url":"https://avatars2.githubusercontent.com/u/4266996?v=4","gravatar_id":"","url":"https://api.github.com/users/bigmstone","html_url":"https://github.com/bigmstone","followers_url":"https://api.github.com/users/bigmstone/followers","following_url":"https://api.github.com/users/bigmstone/following{/other_user}","gists_url":"https://api.github.com/users/bigmstone/gists{/gist_id}","starred_url":"https://api.github.com/users/bigmstone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigmstone/subscriptions","organizations_url":"https://api.github.com/users/bigmstone/orgs","repos_url":"https://api.github.com/users/bigmstone/repos","events_url":"https://api.github.com/users/bigmstone/events{/privacy}","received_events_url":"https://api.github.com/users/bigmstone/received_events","type":"User","site_admin":false},"body":"On execution creation there should be a way to delay the task by a specified amount of time. This PR provides a mechanism to specify in the the delay in milliseconds.","created_at":"2018-10-17T15:23:26Z","updated_at":"2018-11-08T23:16:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bb63decfa99f5f3bbfe9f94bb3313a9f0c4d0813","assignee":{"login":"bigmstone","id":4266996,"node_id":"MDQ6VXNlcjQyNjY5OTY=","avatar_url":"https://avatars2.githubusercontent.com/u/4266996?v=4","gravatar_id":"","url":"https://api.github.com/users/bigmstone","html_url":"https://github.com/bigmstone","followers_url":"https://api.github.com/users/bigmstone/followers","following_url":"https://api.github.com/users/bigmstone/following{/other_user}","gists_url":"https://api.github.com/users/bigmstone/gists{/gist_id}","starred_url":"https://api.github.com/users/bigmstone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigmstone/subscriptions","organizations_url":"https://api.github.com/users/bigmstone/orgs","repos_url":"https://api.github.com/users/bigmstone/repos","events_url":"https://api.github.com/users/bigmstone/events{/privacy}","received_events_url":"https://api.github.com/users/bigmstone/received_events","type":"User","site_admin":false},"assignees":[{"login":"bigmstone","id":4266996,"node_id":"MDQ6VXNlcjQyNjY5OTY=","avatar_url":"https://avatars2.githubusercontent.com/u/4266996?v=4","gravatar_id":"","url":"https://api.github.com/users/bigmstone","html_url":"https://github.com/bigmstone","followers_url":"https://api.github.com/users/bigmstone/followers","following_url":"https://api.github.com/users/bigmstone/following{/other_user}","gists_url":"https://api.github.com/users/bigmstone/gists{/gist_id}","starred_url":"https://api.github.com/users/bigmstone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigmstone/subscriptions","organizations_url":"https://api.github.com/users/bigmstone/orgs","repos_url":"https://api.github.com/users/bigmstone/repos","events_url":"https://api.github.com/users/bigmstone/events{/privacy}","received_events_url":"https://api.github.com/users/bigmstone/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":195099449,"node_id":"MDU6TGFiZWwxOTUwOTk0NDk=","url":"https://api.github.com/repos/StackStorm/st2/labels/WIP","name":"WIP","color":"bfdadc","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/StackStorm/st2/pulls/4397/commits","review_comments_url":"https://api.github.com/repos/StackStorm/st2/pulls/4397/comments","review_comment_url":"https://api.github.com/repos/StackStorm/st2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/StackStorm/st2/issues/4397/comments","statuses_url":"https://api.github.com/repos/StackStorm/st2/statuses/e713fd80940bba2b001c58e1f42a20ffd707c6d2","head":{"label":"StackStorm:scheduler-delay","ref":"scheduler-delay","sha":"e713fd80940bba2b001c58e1f42a20ffd707c6d2","user":{"login":"StackStorm","id":4969009,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ5NjkwMDk=","avatar_url":"https://avatars3.githubusercontent.com/u/4969009?v=4","gravatar_id":"","url":"https://api.github.com/users/StackStorm","html_url":"https://github.com/StackStorm","followers_url":"https://api.github.com/users/StackStorm/followers","following_url":"https://api.github.com/users/StackStorm/following{/other_user}","gists_url":"https://api.github.com/users/StackStorm/gists{/gist_id}","starred_url":"https://api.github.com/users/StackStorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StackStorm/subscriptions","organizations_url":"https://api.github.com/users/StackStorm/orgs","repos_url":"https://api.github.com/users/StackStorm/repos","events_url":"https://api.github.com/users/StackStorm/events{/privacy}","received_events_url":"https://api.github.com/users/StackStorm/received_events","type":"Organization","site_admin":false},"repo":{"id":19051806,"node_id":"MDEwOlJlcG9zaXRvcnkxOTA1MTgwNg==","name":"st2","full_name":"StackStorm/st2","private":false,"owner":{"login":"StackStorm","id":4969009,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ5NjkwMDk=","avatar_url":"https://avatars3.githubusercontent.com/u/4969009?v=4","gravatar_id":"","url":"https://api.github.com/users/StackStorm","html_url":"https://github.com/StackStorm","followers_url":"https://api.github.com/users/StackStorm/followers","following_url":"https://api.github.com/users/StackStorm/following{/other_user}","gists_url":"https://api.github.com/users/StackStorm/gists{/gist_id}","starred_url":"https://api.github.com/users/StackStorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StackStorm/subscriptions","organizations_url":"https://api.github.com/users/StackStorm/orgs","repos_url":"https://api.github.com/users/StackStorm/repos","events_url":"https://api.github.com/users/StackStorm/events{/privacy}","received_events_url":"https://api.github.com/users/StackStorm/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/StackStorm/st2","description":"StackStorm (aka \"IFTTT for Ops\") is event-driven automation for auto-remediation, security responses, troubleshooting, deployments, and more. Includes rules engine, workflow, 2000+ integrations (see https://exchange.stackstorm.org), ChatOps, etc. Installer at https://docs.stackstorm.com/install/index.html. Questions? https://forum.stackstorm.com/.","fork":false,"url":"https://api.github.com/repos/StackStorm/st2","forks_url":"https://api.github.com/repos/StackStorm/st2/forks","keys_url":"https://api.github.com/repos/StackStorm/st2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StackStorm/st2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StackStorm/st2/teams","hooks_url":"https://api.github.com/repos/StackStorm/st2/hooks","issue_events_url":"https://api.github.com/repos/StackStorm/st2/issues/events{/number}","events_url":"https://api.github.com/repos/StackStorm/st2/events","assignees_url":"https://api.github.com/repos/StackStorm/st2/assignees{/user}","branches_url":"https://api.github.com/repos/StackStorm/st2/branches{/branch}","tags_url":"https://api.github.com/repos/StackStorm/st2/tags","blobs_url":"https://api.github.com/repos/StackStorm/st2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StackStorm/st2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StackStorm/st2/git/refs{/sha}","trees_url":"https://api.github.com/repos/StackStorm/st2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StackStorm/st2/statuses/{sha}","languages_url":"https://api.github.com/repos/StackStorm/st2/languages","stargazers_url":"https://api.github.com/repos/StackStorm/st2/stargazers","contributors_url":"https://api.github.com/repos/StackStorm/st2/contributors","subscribers_url":"https://api.github.com/repos/StackStorm/st2/subscribers","subscription_url":"https://api.github.com/repos/StackStorm/st2/subscription","commits_url":"https://api.github.com/repos/StackStorm/st2/commits{/sha}","git_commits_url":"https://api.github.com/repos/StackStorm/st2/git/commits{/sha}","comments_url":"https://api.github.com/repos/StackStorm/st2/comments{/number}","issue_comment_url":"https://api.github.com/repos/StackStorm/st2/issues/comments{/number}","contents_url":"https://api.github.com/repos/StackStorm/st2/contents/{+path}","compare_url":"https://api.github.com/repos/StackStorm/st2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StackStorm/st2/merges","archive_url":"https://api.github.com/repos/StackStorm/st2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StackStorm/st2/downloads","issues_url":"https://api.github.com/repos/StackStorm/st2/issues{/number}","pulls_url":"https://api.github.com/repos/StackStorm/st2/pulls{/number}","milestones_url":"https://api.github.com/repos/StackStorm/st2/milestones{/number}","notifications_url":"https://api.github.com/repos/StackStorm/st2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StackStorm/st2/labels{/name}","releases_url":"https://api.github.com/repos/StackStorm/st2/releases{/id}","deployments_url":"https://api.github.com/repos/StackStorm/st2/deployments","created_at":"2014-04-23T00:51:34Z","updated_at":"2018-11-08T21:42:44Z","pushed_at":"2018-11-08T22:36:19Z","git_url":"git://github.com/StackStorm/st2.git","ssh_url":"git@github.com:StackStorm/st2.git","clone_url":"https://github.com/StackStorm/st2.git","svn_url":"https://github.com/StackStorm/st2","homepage":"http://www.stackstorm.com/","size":26126,"stargazers_count":2867,"watchers_count":2867,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":388,"mirror_url":null,"archived":false,"open_issues_count":347,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":388,"open_issues":347,"watchers":2867,"default_branch":"master"}},"base":{"label":"StackStorm:master","ref":"master","sha":"87254b8f9a9e746729167d43d5fc376cfb51ac2e","user":{"login":"StackStorm","id":4969009,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ5NjkwMDk=","avatar_url":"https://avatars3.githubusercontent.com/u/4969009?v=4","gravatar_id":"","url":"https://api.github.com/users/StackStorm","html_url":"https://github.com/StackStorm","followers_url":"https://api.github.com/users/StackStorm/followers","following_url":"https://api.github.com/users/StackStorm/following{/other_user}","gists_url":"https://api.github.com/users/StackStorm/gists{/gist_id}","starred_url":"https://api.github.com/users/StackStorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StackStorm/subscriptions","organizations_url":"https://api.github.com/users/StackStorm/orgs","repos_url":"https://api.github.com/users/StackStorm/repos","events_url":"https://api.github.com/users/StackStorm/events{/privacy}","received_events_url":"https://api.github.com/users/StackStorm/received_events","type":"Organization","site_admin":false},"repo":{"id":19051806,"node_id":"MDEwOlJlcG9zaXRvcnkxOTA1MTgwNg==","name":"st2","full_name":"StackStorm/st2","private":false,"owner":{"login":"StackStorm","id":4969009,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ5NjkwMDk=","avatar_url":"https://avatars3.githubusercontent.com/u/4969009?v=4","gravatar_id":"","url":"https://api.github.com/users/StackStorm","html_url":"https://github.com/StackStorm","followers_url":"https://api.github.com/users/StackStorm/followers","following_url":"https://api.github.com/users/StackStorm/following{/other_user}","gists_url":"https://api.github.com/users/StackStorm/gists{/gist_id}","starred_url":"https://api.github.com/users/StackStorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StackStorm/subscriptions","organizations_url":"https://api.github.com/users/StackStorm/orgs","repos_url":"https://api.github.com/users/StackStorm/repos","events_url":"https://api.github.com/users/StackStorm/events{/privacy}","received_events_url":"https://api.github.com/users/StackStorm/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/StackStorm/st2","description":"StackStorm (aka \"IFTTT for Ops\") is event-driven automation for auto-remediation, security responses, troubleshooting, deployments, and more. Includes rules engine, workflow, 2000+ integrations (see https://exchange.stackstorm.org), ChatOps, etc. Installer at https://docs.stackstorm.com/install/index.html. Questions? https://forum.stackstorm.com/.","fork":false,"url":"https://api.github.com/repos/StackStorm/st2","forks_url":"https://api.github.com/repos/StackStorm/st2/forks","keys_url":"https://api.github.com/repos/StackStorm/st2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StackStorm/st2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StackStorm/st2/teams","hooks_url":"https://api.github.com/repos/StackStorm/st2/hooks","issue_events_url":"https://api.github.com/repos/StackStorm/st2/issues/events{/number}","events_url":"https://api.github.com/repos/StackStorm/st2/events","assignees_url":"https://api.github.com/repos/StackStorm/st2/assignees{/user}","branches_url":"https://api.github.com/repos/StackStorm/st2/branches{/branch}","tags_url":"https://api.github.com/repos/StackStorm/st2/tags","blobs_url":"https://api.github.com/repos/StackStorm/st2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StackStorm/st2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StackStorm/st2/git/refs{/sha}","trees_url":"https://api.github.com/repos/StackStorm/st2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StackStorm/st2/statuses/{sha}","languages_url":"https://api.github.com/repos/StackStorm/st2/languages","stargazers_url":"https://api.github.com/repos/StackStorm/st2/stargazers","contributors_url":"https://api.github.com/repos/StackStorm/st2/contributors","subscribers_url":"https://api.github.com/repos/StackStorm/st2/subscribers","subscription_url":"https://api.github.com/repos/StackStorm/st2/subscription","commits_url":"https://api.github.com/repos/StackStorm/st2/commits{/sha}","git_commits_url":"https://api.github.com/repos/StackStorm/st2/git/commits{/sha}","comments_url":"https://api.github.com/repos/StackStorm/st2/comments{/number}","issue_comment_url":"https://api.github.com/repos/StackStorm/st2/issues/comments{/number}","contents_url":"https://api.github.com/repos/StackStorm/st2/contents/{+path}","compare_url":"https://api.github.com/repos/StackStorm/st2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StackStorm/st2/merges","archive_url":"https://api.github.com/repos/StackStorm/st2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StackStorm/st2/downloads","issues_url":"https://api.github.com/repos/StackStorm/st2/issues{/number}","pulls_url":"https://api.github.com/repos/StackStorm/st2/pulls{/number}","milestones_url":"https://api.github.com/repos/StackStorm/st2/milestones{/number}","notifications_url":"https://api.github.com/repos/StackStorm/st2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StackStorm/st2/labels{/name}","releases_url":"https://api.github.com/repos/StackStorm/st2/releases{/id}","deployments_url":"https://api.github.com/repos/StackStorm/st2/deployments","created_at":"2014-04-23T00:51:34Z","updated_at":"2018-11-08T21:42:44Z","pushed_at":"2018-11-08T22:36:19Z","git_url":"git://github.com/StackStorm/st2.git","ssh_url":"git@github.com:StackStorm/st2.git","clone_url":"https://github.com/StackStorm/st2.git","svn_url":"https://github.com/StackStorm/st2","homepage":"http://www.stackstorm.com/","size":26126,"stargazers_count":2867,"watchers_count":2867,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":388,"mirror_url":null,"archived":false,"open_issues_count":347,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":388,"open_issues":347,"watchers":2867,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/StackStorm/st2/pulls/4397"},"html":{"href":"https://github.com/StackStorm/st2/pull/4397"},"issue":{"href":"https://api.github.com/repos/StackStorm/st2/issues/4397"},"comments":{"href":"https://api.github.com/repos/StackStorm/st2/issues/4397/comments"},"review_comments":{"href":"https://api.github.com/repos/StackStorm/st2/pulls/4397/comments"},"review_comment":{"href":"https://api.github.com/repos/StackStorm/st2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/StackStorm/st2/pulls/4397/commits"},"statuses":{"href":"https://api.github.com/repos/StackStorm/st2/statuses/e713fd80940bba2b001c58e1f42a20ffd707c6d2"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"m4dcoder"}}