Skip to content

Instantly share code, notes, and snippets.

View RafaelAPB's full-sized avatar
🎯
Focusing

Rafael Belchior RafaelAPB

🎯
Focusing
View GitHub Profile
@affo
affo / 2pc.py
Created October 17, 2016 11:06
Implementation of 2 Phase Commit protocol
'''
Implementation of 2 Phase Commit as explained at Wikipedia:
https://en.wikipedia.org/wiki/Two-phase_commit_protocol
'''
import random, logging, time
from threading import Thread, Semaphore, Lock
_fmt = '%(user)s:%(levelname)s >>> %(message)s'
logging.basicConfig(format=_fmt)
LOG = logging.getLogger(__name__)