5ac72fcb3d
The tooz project doesn't support Python 2 anymore, using the six library should not be necessary. Change-Id: I9886cabcd13cbc615065ceb372efbf037dff1aeb
21 lines
459 B
Python
21 lines
459 B
Python
import uuid
|
|
|
|
from tooz import coordination
|
|
|
|
coordinator = coordination.get_coordinator('zake://', b'host-1')
|
|
coordinator.start()
|
|
|
|
# Create a group
|
|
group = bytes(str(uuid.uuid4()).encode('ascii'))
|
|
request = coordinator.create_group(group)
|
|
request.get()
|
|
|
|
|
|
def group_joined(event):
|
|
# Event is an instance of tooz.coordination.MemberJoinedGroup
|
|
print(event.group_id, event.member_id)
|
|
|
|
|
|
coordinator.watch_join_group(group, group_joined)
|
|
coordinator.stop()
|