open-things / loggingex

Extensions for the standard logging module.
MIT License
2 stars 4 forks source link

Bug in decorator implementation #8

Closed Paulius-Maruska closed 5 years ago

Paulius-Maruska commented 5 years ago

I haven't tested this yet, but there should be bug right now with the decorator.

ContextChange can not be applied twice, so if it is used as a decorator on recursive function, or the function is being called by multiple threads - it should raise an exception the second time it's called (but before the first call was completed).

Possible solution - copy ContextChange instance and apply the copy of it, within the decorated internal function, to make the ContextChange local variable. That should do the trick.

Paulius-Maruska commented 5 years ago

Ok, I just write a test with a recursive function - it does indeed raise an exception. So, bug confirmed, I guess.