Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread-safe version of with-spy and with-stub #45

Closed
mourjo opened this issue Mar 11, 2019 · 2 comments
Closed

Thread-safe version of with-spy and with-stub #45

mourjo opened this issue Mar 11, 2019 · 2 comments

Comments

@mourjo
Copy link

mourjo commented Mar 11, 2019

Bond uses with-redefs which binds the function's var's root to the new definition, which means it is visible to all threads that are currently executing, not necessarily the one in the context of with-spy or with-stub, for example

(defn funk [& args] args)

(future
  (bond/with-stub! [[funk (constantly -1)]]
    (Thread/sleep 10000)
    (funk)))

(funk 9) ;; => -1 (redefined function being called outside of with-stub)

;; after ten seconds
(funk 9) ;; => (9)

I was curious if you think using thread-local redefinitions is something you think would be useful here. For example, using https://gist.github.com/gfredericks/7143494

@mourjo
Copy link
Author

mourjo commented Jul 13, 2020

Hello, was wondering if there is an update on this? Have been using this patch for a while, would like to have it in a stable release!

@neeasade
Copy link
Contributor

neeasade commented May 5, 2021

closing -- see #47 (comment)

@neeasade neeasade closed this as completed May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants