Skip to content

Instantly share code, notes, and snippets.

@bashwork
bashwork / ThreadSafeDataBlock.py
Created October 23, 2013 03:32
This is a simple decorator for a DataBlock using a quickly mocked up reader writer lock that is biased towards writing.
import threading
from contextlib import contextmanager
from pymodbus.datastore.store import BaseModbusDataBlock
class ContextWrapper(object):
''' This is a simple wrapper around enter
and exit functions that conforms to the pyhton
context manager protocol: