How make your module substitute a python stdlib module.

Antoon Pardon antoon.pardon at vub.be
Tue Dec 27 07:26:37 EST 2022



Op 27/12/2022 om 13:09 schreef Chris Angelico:
> On Tue, 27 Dec 2022 at 23:06, Antoon Pardon<antoon.pardon at vub.be>  wrote:
>>> How do you intend to distinguish one from the other? How should the
>>> logging module know which threading module to use?
>> That is my question! How can I get the logging module to use my module.I was hoping the logging module would allow some kind of dependency
>> injection, so you can tell it what threading module to use. An other
>> option might be to manipulate sys.modules. -- Antoon Pardon
> But presumably you want OTHER modules to continue using the vanilla
> threading module? This is likely to end up somewhat hacky. Yes, you
> can manipulate sys.modules, but there's only one threading module at a
> time, so you need a way to distinguish between modules that should use
> the changed one and modules that shouldn't.

But don't these caveats also apply with your original answer of having a
local threading.py file?

At the moment I am happy with a solution that once the programmer has
imported from QYZlib.threaders that module will used as the threading
module.

-- 
Antoon Pardon.


More information about the Python-list mailing list