Created
July 14, 2020 14:18
-
-
Save pshchelo/655d077a1b0e90a4b575999e1e9f91b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Test MySQL tooz driver.""" | |
import os | |
import platform | |
import time | |
from tooz import coordination | |
url = os.getenv("MYSQL_URL") | |
host = "mysql-test-%s" % platform.node() | |
lock_name = "foo" | |
hold = 60 | |
coord = coordination.get_coordinator(url, host) | |
coord.start(start_heart=True) | |
lock = coord.get_lock("lock_name") | |
print("Attempting to get lock %s for %s" % (lock_name, host)) | |
with lock(blocking=True): | |
print("Got lock %s for %s, holding for %i sec" % (lock_name, host, hold)) | |
time.sleep(hold) | |
coord.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment