How to Lock a Function Across Processes with a Decorator in Python

Sometimes several processes can call the same function at once, even though its logic is completely unsuited to that. One worker changes the password for an external system, another does exactly the same thing, and a third is trying to log in. Everyone meant well, but now nobody knows the current password XD. A similar problem comes up when refreshing shared data, generating the same report, or modifying a file. If these operations get in each other’s way, we get a classic race condition: a race where the winner sometimes turns out to be an error message. ...

October 8, 2026 · 6 min · SpaceShaman

How to Add Logging Without Cluttering Your Code

In one of my Python projects, I needed to create fairly detailed logs describing the program’s execution. Most of the project is glue code that uses numerous external services and automates processes that were previously performed manually. I do not have full control over them, and my knowledge of how they work is very limited. Because different processes often use the same services, I wrapped those services in classes. The code implementing one of these automations looks roughly like this: ...

August 27, 2026 · 7 min · SpaceShaman