{"action":"created","comment":{"url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/comments/64738064","id":64738064,"diff_hunk":"@@ -141,14 +162,69 @@ def stop(self):\n         with self.__lock:\n             self.running = False\n \n-    class Job(object):\n-        \"\"\" Inner class that represents a job \"\"\"\n-        interval = None\n-        name = None\n-        repeat = None\n+        self.__tick.set()\n+\n+    def jobs(self):\n+        \"\"\"Returns a tuple of all jobs that are currently in the ``JobQueue``\"\"\"\n+        return tuple(job[1] for job in self.queue.queue if job)\n+\n+\n+class Job(object):\n+    \"\"\"This class encapsulates a Job\n+\n+    Attributes:\n+        callback (function):\n+        interval (float):\n+        repeat (bool):\n+        name (str):\n+        enabled (bool): If this job is currently active\n+\n+    Args:\n+        callback (function): The callback function that should be executed by the Job. It should\n+            take two parameters ``bot`` and ``job``, where ``job`` is the ``Job`` instance. It\n+            can be used to terminate the job or modify its interval.\n+        interval (float): The interval in which this job should execute its callback function in\n+            seconds.\n+        repeat (Optional[bool]): If this job should be periodically execute its callback function\n+            (``True``) or only once (``False``). Defaults to ``True``\n+        context (Optional[object]): Additional data needed for the callback function. Can be\n+            accessed through ``job.context`` in the callback. Defaults to ``None``\n+\n+    \"\"\"\n+    job_queue = None\n+\n+    def __init__(self, callback, interval, repeat=True, context=None):\n+        self.callback = callback\n+        self.interval = interval\n+        self.repeat = repeat\n+        self.context = context\n+\n+        self.name = callback.__name__\n+        self._remove = Event()\n+        self._enabled = Event()\n+        self._enabled.set()\n+\n+    def run(self):\n+        \"\"\"Executes the callback function\"\"\"\n+        self.callback(self.job_queue.bot, self)","path":"telegram/ext/jobqueue.py","position":233,"original_position":211,"commit_id":"bb165b6acf37abcd583466770df0c80aa490e550","original_commit_id":"786216305cfb1e1fe201ae9f04ffe8995bf95a58","user":{"login":"jh0ker","id":3945220,"avatar_url":"https://avatars.githubusercontent.com/u/3945220?v=3","gravatar_id":"","url":"https://api.github.com/users/jh0ker","html_url":"https://github.com/jh0ker","followers_url":"https://api.github.com/users/jh0ker/followers","following_url":"https://api.github.com/users/jh0ker/following{/other_user}","gists_url":"https://api.github.com/users/jh0ker/gists{/gist_id}","starred_url":"https://api.github.com/users/jh0ker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jh0ker/subscriptions","organizations_url":"https://api.github.com/users/jh0ker/orgs","repos_url":"https://api.github.com/users/jh0ker/repos","events_url":"https://api.github.com/users/jh0ker/events{/privacy}","received_events_url":"https://api.github.com/users/jh0ker/received_events","type":"User","site_admin":false},"body":"This method is used by the job queue, though of course you can also run it from outside.","created_at":"2016-05-26T12:42:48Z","updated_at":"2016-05-26T12:42:48Z","html_url":"https://github.com/python-telegram-bot/python-telegram-bot/pull/307#discussion_r64738064","pull_request_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/307","_links":{"self":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/comments/64738064"},"html":{"href":"https://github.com/python-telegram-bot/python-telegram-bot/pull/307#discussion_r64738064"},"pull_request":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/307"}}},"pull_request":{"url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/307","id":71464372,"html_url":"https://github.com/python-telegram-bot/python-telegram-bot/pull/307","diff_url":"https://github.com/python-telegram-bot/python-telegram-bot/pull/307.diff","patch_url":"https://github.com/python-telegram-bot/python-telegram-bot/pull/307.patch","issue_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/307","number":307,"state":"open","locked":false,"title":"Make job queue API similar to the dispatcher, add new functionality","user":{"login":"jh0ker","id":3945220,"avatar_url":"https://avatars.githubusercontent.com/u/3945220?v=3","gravatar_id":"","url":"https://api.github.com/users/jh0ker","html_url":"https://github.com/jh0ker","followers_url":"https://api.github.com/users/jh0ker/followers","following_url":"https://api.github.com/users/jh0ker/following{/other_user}","gists_url":"https://api.github.com/users/jh0ker/gists{/gist_id}","starred_url":"https://api.github.com/users/jh0ker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jh0ker/subscriptions","organizations_url":"https://api.github.com/users/jh0ker/orgs","repos_url":"https://api.github.com/users/jh0ker/repos","events_url":"https://api.github.com/users/jh0ker/events{/privacy}","received_events_url":"https://api.github.com/users/jh0ker/received_events","type":"User","site_admin":false},"body":"The `JobQueue` API has been changed to look similar to the 4.x `Dispatcher` API\r\n\r\nInstead of simply passing a callback function to the `JobQueue.put` method, you now have to pass a `Job` object, which `__init__` takes now the arguments `callback`, `interval` and `repeat` (these were passed to `put` before).\r\n\r\nThe `Job` class exposes the boolean property `enabled`, which you can use to pause execution of the job temporarily, and the method `schedule_removal`, which marks the job for complete removal from the queue. *Note:* Because the `JobQueue` internally uses a `PriorityQueue`, the job will remain in the queue until it is at the front of the queue, but it will not be executed again.\r\nIn addition to the `bot` argument, callback functions now receive their respective `Job` object in an argument called `job`.\r\n\r\nThe `JobQueue` class now has a `jobs` method, which returns a `tuple` of all jobs currently in the queue.\r\n\r\n*Under the hood*\r\nInstead of continuously checking if any jobs should run, the `JobQueue` now waits until the next job is due. If a new job is added in the meantime, the waiting time is re-calculated as necessary. As a result, the `ticking_interval` argument has been removed from both `JobQueue` and `Updater`.","created_at":"2016-05-25T21:15:21Z","updated_at":"2016-05-26T12:42:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b3412c718a905123ea748941dc49f93fc76b796","assignee":{"login":"tsnoam","id":7777017,"avatar_url":"https://avatars.githubusercontent.com/u/7777017?v=3","gravatar_id":"","url":"https://api.github.com/users/tsnoam","html_url":"https://github.com/tsnoam","followers_url":"https://api.github.com/users/tsnoam/followers","following_url":"https://api.github.com/users/tsnoam/following{/other_user}","gists_url":"https://api.github.com/users/tsnoam/gists{/gist_id}","starred_url":"https://api.github.com/users/tsnoam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsnoam/subscriptions","organizations_url":"https://api.github.com/users/tsnoam/orgs","repos_url":"https://api.github.com/users/tsnoam/repos","events_url":"https://api.github.com/users/tsnoam/events{/privacy}","received_events_url":"https://api.github.com/users/tsnoam/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/milestones/3","html_url":"https://github.com/python-telegram-bot/python-telegram-bot/milestones/5.0","labels_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/milestones/3/labels","id":1729004,"number":3,"title":"5.0","description":"","creator":{"login":"leandrotoledo","id":615742,"avatar_url":"https://avatars.githubusercontent.com/u/615742?v=3","gravatar_id":"","url":"https://api.github.com/users/leandrotoledo","html_url":"https://github.com/leandrotoledo","followers_url":"https://api.github.com/users/leandrotoledo/followers","following_url":"https://api.github.com/users/leandrotoledo/following{/other_user}","gists_url":"https://api.github.com/users/leandrotoledo/gists{/gist_id}","starred_url":"https://api.github.com/users/leandrotoledo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leandrotoledo/subscriptions","organizations_url":"https://api.github.com/users/leandrotoledo/orgs","repos_url":"https://api.github.com/users/leandrotoledo/repos","events_url":"https://api.github.com/users/leandrotoledo/events{/privacy}","received_events_url":"https://api.github.com/users/leandrotoledo/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":1,"state":"open","created_at":"2016-04-25T13:36:19Z","updated_at":"2016-05-25T23:03:02Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/307/commits","review_comments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/307/comments","review_comment_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/307/comments","statuses_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/statuses/bb165b6acf37abcd583466770df0c80aa490e550","head":{"label":"python-telegram-bot:jobqueue-rework","ref":"jobqueue-rework","sha":"bb165b6acf37abcd583466770df0c80aa490e550","user":{"login":"python-telegram-bot","id":16178365,"avatar_url":"https://avatars.githubusercontent.com/u/16178365?v=3","gravatar_id":"","url":"https://api.github.com/users/python-telegram-bot","html_url":"https://github.com/python-telegram-bot","followers_url":"https://api.github.com/users/python-telegram-bot/followers","following_url":"https://api.github.com/users/python-telegram-bot/following{/other_user}","gists_url":"https://api.github.com/users/python-telegram-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/python-telegram-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-telegram-bot/subscriptions","organizations_url":"https://api.github.com/users/python-telegram-bot/orgs","repos_url":"https://api.github.com/users/python-telegram-bot/repos","events_url":"https://api.github.com/users/python-telegram-bot/events{/privacy}","received_events_url":"https://api.github.com/users/python-telegram-bot/received_events","type":"Organization","site_admin":false},"repo":{"id":38696925,"name":"python-telegram-bot","full_name":"python-telegram-bot/python-telegram-bot","owner":{"login":"python-telegram-bot","id":16178365,"avatar_url":"https://avatars.githubusercontent.com/u/16178365?v=3","gravatar_id":"","url":"https://api.github.com/users/python-telegram-bot","html_url":"https://github.com/python-telegram-bot","followers_url":"https://api.github.com/users/python-telegram-bot/followers","following_url":"https://api.github.com/users/python-telegram-bot/following{/other_user}","gists_url":"https://api.github.com/users/python-telegram-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/python-telegram-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-telegram-bot/subscriptions","organizations_url":"https://api.github.com/users/python-telegram-bot/orgs","repos_url":"https://api.github.com/users/python-telegram-bot/repos","events_url":"https://api.github.com/users/python-telegram-bot/events{/privacy}","received_events_url":"https://api.github.com/users/python-telegram-bot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python-telegram-bot/python-telegram-bot","description":"Not just a Python wrapper around the Telegram Bot API.","fork":false,"url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot","forks_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/forks","keys_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/teams","hooks_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/hooks","issue_events_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/events{/number}","events_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/events","assignees_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/assignees{/user}","branches_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/branches{/branch}","tags_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/tags","blobs_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/languages","stargazers_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/stargazers","contributors_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/contributors","subscribers_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/subscribers","subscription_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/subscription","commits_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/contents/{+path}","compare_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/merges","archive_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/downloads","issues_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues{/number}","pulls_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/labels{/name}","releases_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/releases{/id}","deployments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/deployments","created_at":"2015-07-07T15:30:39Z","updated_at":"2016-05-26T10:31:13Z","pushed_at":"2016-05-26T12:39:24Z","git_url":"git://github.com/python-telegram-bot/python-telegram-bot.git","ssh_url":"git@github.com:python-telegram-bot/python-telegram-bot.git","clone_url":"https://github.com/python-telegram-bot/python-telegram-bot.git","svn_url":"https://github.com/python-telegram-bot/python-telegram-bot","homepage":"https://python-telegram-bot.org","size":2025,"stargazers_count":921,"watchers_count":921,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":225,"mirror_url":null,"open_issues_count":16,"forks":225,"open_issues":16,"watchers":921,"default_branch":"master"}},"base":{"label":"python-telegram-bot:master","ref":"master","sha":"d90b0f495d628aa3bbaab4f68d654fbeae2c503b","user":{"login":"python-telegram-bot","id":16178365,"avatar_url":"https://avatars.githubusercontent.com/u/16178365?v=3","gravatar_id":"","url":"https://api.github.com/users/python-telegram-bot","html_url":"https://github.com/python-telegram-bot","followers_url":"https://api.github.com/users/python-telegram-bot/followers","following_url":"https://api.github.com/users/python-telegram-bot/following{/other_user}","gists_url":"https://api.github.com/users/python-telegram-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/python-telegram-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-telegram-bot/subscriptions","organizations_url":"https://api.github.com/users/python-telegram-bot/orgs","repos_url":"https://api.github.com/users/python-telegram-bot/repos","events_url":"https://api.github.com/users/python-telegram-bot/events{/privacy}","received_events_url":"https://api.github.com/users/python-telegram-bot/received_events","type":"Organization","site_admin":false},"repo":{"id":38696925,"name":"python-telegram-bot","full_name":"python-telegram-bot/python-telegram-bot","owner":{"login":"python-telegram-bot","id":16178365,"avatar_url":"https://avatars.githubusercontent.com/u/16178365?v=3","gravatar_id":"","url":"https://api.github.com/users/python-telegram-bot","html_url":"https://github.com/python-telegram-bot","followers_url":"https://api.github.com/users/python-telegram-bot/followers","following_url":"https://api.github.com/users/python-telegram-bot/following{/other_user}","gists_url":"https://api.github.com/users/python-telegram-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/python-telegram-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-telegram-bot/subscriptions","organizations_url":"https://api.github.com/users/python-telegram-bot/orgs","repos_url":"https://api.github.com/users/python-telegram-bot/repos","events_url":"https://api.github.com/users/python-telegram-bot/events{/privacy}","received_events_url":"https://api.github.com/users/python-telegram-bot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python-telegram-bot/python-telegram-bot","description":"Not just a Python wrapper around the Telegram Bot API.","fork":false,"url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot","forks_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/forks","keys_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/teams","hooks_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/hooks","issue_events_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/events{/number}","events_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/events","assignees_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/assignees{/user}","branches_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/branches{/branch}","tags_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/tags","blobs_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/languages","stargazers_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/stargazers","contributors_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/contributors","subscribers_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/subscribers","subscription_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/subscription","commits_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/contents/{+path}","compare_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/merges","archive_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/downloads","issues_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues{/number}","pulls_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/labels{/name}","releases_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/releases{/id}","deployments_url":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/deployments","created_at":"2015-07-07T15:30:39Z","updated_at":"2016-05-26T10:31:13Z","pushed_at":"2016-05-26T12:39:24Z","git_url":"git://github.com/python-telegram-bot/python-telegram-bot.git","ssh_url":"git@github.com:python-telegram-bot/python-telegram-bot.git","clone_url":"https://github.com/python-telegram-bot/python-telegram-bot.git","svn_url":"https://github.com/python-telegram-bot/python-telegram-bot","homepage":"https://python-telegram-bot.org","size":2025,"stargazers_count":921,"watchers_count":921,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":225,"mirror_url":null,"open_issues_count":16,"forks":225,"open_issues":16,"watchers":921,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/307"},"html":{"href":"https://github.com/python-telegram-bot/python-telegram-bot/pull/307"},"issue":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/307"},"comments":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/issues/307/comments"},"review_comments":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/307/comments"},"review_comment":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/pulls/307/commits"},"statuses":{"href":"https://api.github.com/repos/python-telegram-bot/python-telegram-bot/statuses/bb165b6acf37abcd583466770df0c80aa490e550"}}}}
{"actor":{"display_login":"jh0ker"}}