-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
issue when multiple threads accessing the registeredCalls dictionary #20
Comments
Hi @vigdora I haven't run into this, do you use multithreading in your tests? |
Hi @danielsaidi
when I wrapped this code with serialQueue, it stopped crashing:
do you run unitests on one thread only? |
I usually don't change the default Xcode test setup, and assumed that running tests in parallel would still use isolated processes. So if you see this crash in the default setup, some form of thread safety is probably needed. |
@danielsaidi thanks for the quick reply.
now lets assume oneRepo is mocked, |
Thank you, that's great information 👍 Async functions run on different threads, so that is most definitely the problem. Perhaps it would be worth making the mock a main actor? |
yee I think thats a possible solution ( I will make sure it works in the meantime...) |
I most definitively want to add such a solution within the library itself, so devs don't have to do anything. I only wish I can find a way to reproduce the problem. |
@danielsaidi |
Thank you for continuing to look at this! I am unfortunately very busy with a few other projects, so I will not have time to look at this problem right now. If you find a way to solve it, I'd be happy to merge it and release a new version. 👍 |
We had similar issues with this so in our fork we use a semaphore to guard the access, it's not the most elegant solution but as a triage it works. https://github.com/BookBeat/MockingKit/tree/thread-safe |
when multiple threads are trying to access mock.registeredCalls it crashes.
any suggestion to a thread safe solution?
The text was updated successfully, but these errors were encountered: