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

Move away from CliRunner in unit tests #47

Open
remyroy opened this issue May 23, 2024 · 5 comments
Open

Move away from CliRunner in unit tests #47

remyroy opened this issue May 23, 2024 · 5 comments
Assignees

Comments

@remyroy
Copy link
Member

remyroy commented May 23, 2024

The CliRunner from Click does not support concurrency which we are going to be using. We should find a better way and move away from using it.

@valefar-on-discord
Copy link
Collaborator

"This only works in single-threaded systems without any concurrency as it changes the global interpreter state."
From documentation

@remyroy
Copy link
Member Author

remyroy commented Jun 3, 2024

Related to #30

@remyroy
Copy link
Member Author

remyroy commented Jun 3, 2024

subprocess or asyncio subprocess are likely to way to go here.

@yorickdowne
Copy link

yorickdowne commented Aug 28, 2024

I suggest we do not use threading. We are CPU-bound, and because of the GIL, threading does not gain us speed: It would if we were IO-bound. See also https://realpython.com/python-gil/

Instead, use multiprocessing. With multiprocessing, every process has its own GIL. That would mean the CLIRunner would continue working, is that right? We'd be single-threaded inside every process.

GIL-less Python has started in 3.13. https://docs.python.org/3.13/whatsnew/3.13.html#free-threaded-cpython It'll be years and years before we can rely on it being the default installation on our target systems and we could consider threading - but tbh multiprocessing will be good enough for our use case, I predict.

I see the value in writing all new tests in [asyncio-]subprocess. Maybe. I note Valefar just wrote a CLIRunner test for partial deposits 😅 .

Existing tests could be a Fleissarbeit, but I don't think it's necessary.

@remyroy
Copy link
Member Author

remyroy commented Sep 6, 2024

CliRunner seems to be working good still even if we are using multiprocessing internally with the concurrent.futures.ProcessPoolExecutor. We might not need to move away from it. This would need more exploration.

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

3 participants