{"action":"created","issue":{"url":"https://api.github.com/repos/juxt/tick/issues/10","repository_url":"https://api.github.com/repos/juxt/tick","labels_url":"https://api.github.com/repos/juxt/tick/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/juxt/tick/issues/10/comments","events_url":"https://api.github.com/repos/juxt/tick/issues/10/events","html_url":"https://github.com/juxt/tick/issues/10","id":263493836,"number":10,"title":"Overlapping scheduled function calls - Can't stop schedule ","user":{"login":"jjfine","id":528749,"avatar_url":"https://avatars1.githubusercontent.com/u/528749?v=4","gravatar_id":"","url":"https://api.github.com/users/jjfine","html_url":"https://github.com/jjfine","followers_url":"https://api.github.com/users/jjfine/followers","following_url":"https://api.github.com/users/jjfine/following{/other_user}","gists_url":"https://api.github.com/users/jjfine/gists{/gist_id}","starred_url":"https://api.github.com/users/jjfine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjfine/subscriptions","organizations_url":"https://api.github.com/users/jjfine/orgs","repos_url":"https://api.github.com/users/jjfine/repos","events_url":"https://api.github.com/users/jjfine/events{/privacy}","received_events_url":"https://api.github.com/users/jjfine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-10-06T15:57:14Z","updated_at":"2017-11-01T07:48:29Z","closed_at":null,"author_association":"NONE","body":"I was trying to see the behavior when calls to a long-running scheduled function overlap. I thought it was working as expected: the scheduled function is called at every tick in the schedule even if another is running. However, I'm unable to stop the schedule. Code to reproduce the issue is below. The issue goes away when removing the `Thread/sleep` or reducing it to less than the schedule interval. Even calling `stop` during the sleep works.\r\n\r\nFor my use case, I'm working on preventing the scheduled function from doing any work when another is in progress so it's not really an issue for me. More just wondering if I'm doing something wrong here.\r\n\r\n```\r\n(require '[tick.schedule :as schedule])\r\n(require '[tick.clock :as clock])\r\n(require '[tick.timeline :as tl])\r\n(require '[tick.core :as tick])\r\n\r\n(defn wait [t]\r\n  (println (format \"waiting for 30s - %s\" t))\r\n  (Thread/sleep 30000)\r\n  (println (format \"done waiting - %s\" t)))\r\n\r\n(defn build-schedule [now]\r\n  (let [evey-ten-secs (tl/periodic-seq now (tick/seconds 10))]\r\n    (schedule/schedule wait\r\n                       (tl/timeline evey-ten-secs))))\r\n\r\n(def my-schedule\r\n  (let [sch (build-schedule (clock/now))]\r\n     (schedule/start sch (clock/clock-ticking-in-seconds))\r\n     sch))\r\n\r\n;; Wait a few seconds and then call:\r\n\r\n(schedule/stop my-schedule)\r\n```"},"comment":{"url":"https://api.github.com/repos/juxt/tick/issues/comments/341023802","html_url":"https://github.com/juxt/tick/issues/10#issuecomment-341023802","issue_url":"https://api.github.com/repos/juxt/tick/issues/10","id":341023802,"user":{"login":"malcolmsparks","id":163131,"avatar_url":"https://avatars2.githubusercontent.com/u/163131?v=4","gravatar_id":"","url":"https://api.github.com/users/malcolmsparks","html_url":"https://github.com/malcolmsparks","followers_url":"https://api.github.com/users/malcolmsparks/followers","following_url":"https://api.github.com/users/malcolmsparks/following{/other_user}","gists_url":"https://api.github.com/users/malcolmsparks/gists{/gist_id}","starred_url":"https://api.github.com/users/malcolmsparks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malcolmsparks/subscriptions","organizations_url":"https://api.github.com/users/malcolmsparks/orgs","repos_url":"https://api.github.com/users/malcolmsparks/repos","events_url":"https://api.github.com/users/malcolmsparks/events{/privacy}","received_events_url":"https://api.github.com/users/malcolmsparks/received_events","type":"User","site_admin":false},"created_at":"2017-11-01T07:48:29Z","updated_at":"2017-11-01T07:48:29Z","author_association":"CONTRIBUTOR","body":"Thanks for this @tomelkin - I can confirm that this is a bug, thanks @jjfine for the test case which made repeating the problem straight-forward.\r\n\r\nThe current algorithm makes the assumption that there is only ever zero or one 'scheduled future' remaining. This is obviously a wrong assumption. The solution may be to shutdown the executor on stop. However, I can't see an obvious way of doing this without the pause functionality being affected. I would have to remove this feature, or find another way. Let me know if you have any ideas, I will do some thinking..."}}
{"actor":{"display_login":"malcolmsparks"}}