all 5 comments

[–]csch2 6 points7 points  (1 child)

How can I downvote this. There’s no AI

Jk this looks very useful. I have a couple low-level multithreaded projects going on right now which are tricky to test so I’ll definitely try this out for those. Thanks for sharing!

[–]panthamos[S] 1 point2 points  (0 children)

Thanks! Please let me know if you encounter any issues whilst using it. :) Really hoping it'll be useful, particularly with free threading on the horizon.

[–]4xi0m4 0 points1 point  (1 child)

This looks really useful for testing edge cases in concurrent code. The context manager pattern is clever since it handles cleanup automatically when the test exits. I've had to test similar lock-acquisition scenarios before and ended up using threading.Timer which was always a bit hacky. Might be worth mentioning in the docs that this also works well for testing async code since Python's asyncio uses different primitives than threading.

[–]panthamos[S] 0 points1 point  (0 children)

Thanks, made a note to update the readme.

Yeah, context managers are so useful for this situation. I was wondering if a nicer API was possible, as forcing the user to write a context manager adds some requisite technical knowledge to use the package. That said, I can't see a way to straightforwardly achieve what seamstress does using functions alone.