tooz/examples/group_membership_watch.py
Riccardo Pittau 5ac72fcb3d Remove six library
The tooz project doesn't support Python 2 anymore, using the
six library should not be necessary.

Change-Id: I9886cabcd13cbc615065ceb372efbf037dff1aeb
2020-07-01 15:56:53 +02:00

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()