kaizendorks / pymongo_inmemory

A mongo mocking library with an ephemeral MongoDB running in memory.
MIT License
40 stars 13 forks source link

Don't add signals if not in main thread #40

Closed hbfernandes closed 3 years ago

hbfernandes commented 3 years ago

Been having some trouble when including the module from threads other than the main one. I believe this change does not impact any current usage, can you take a look?

hbfernandes commented 3 years ago

I've added a test. It's a simplified version of what happens in my scenario. Let me know if you think it's enough.

The MongoClient instance for me gets created within something similar to that async def main() function, and I don't have control over the main Python thread, as it's part of the underlying framework. So far I've found no way to add signals, or other type of hooks to attach to the thread that is running the loop.

ekarademir commented 3 years ago

Thank you @hbfernandes for the contribution! For future reference, please make sure the GitHub actions pass on your latest commit. I'll sort it out at upstream.

hbfernandes commented 3 years ago

Oh, my bad! Didn't run linting! Could you perhaps consider setting the testing workflow to run on PR, would facilitate PR evaluation in the future.

ekarademir commented 3 years ago

No worries. Nailing down Development process to wiki is one of the tickets :)