Skip to content

Instantly share code, notes, and snippets.

View tomaszhlawiczka's full-sized avatar

Tomasz Hławiczka tomaszhlawiczka

  • TRU SOFTWARE
  • PL
View GitHub Profile
@lonetwin
lonetwin / tracer.py
Created April 14, 2018 20:41
tracer.py - Quick and dirty python 'strace'
#!/usr/bin/python
""" tracer.py: Quick and dirty python 'strace'
"""
import os
import os.path
import sys
import linecache
from functools import wraps
@lonetwin
lonetwin / locked_open.py
Last active December 8, 2022 08:05
Simple python file locking context manager example on linux using python stdlib's `fcntl.flock`
import logging
import fcntl
from contextlib import contextmanager
@contextmanager
def locked_open(filename, mode='r'):
"""locked_open(filename, mode='r') -> <open file object>
Context manager that on entry opens the path `filename`, using `mode`
(default: `r`), and applies an advisory write lock on the file which