Skip to content

Instantly share code, notes, and snippets.

View indradhanush's full-sized avatar

Indradhanush Gupta indradhanush

View GitHub Profile
@indradhanush
indradhanush / zmq_target.py
Created June 16, 2014 19:08
get_sync_info() in zmq
class ZMQSyncTarget(ZMQClientBase, SyncTarget):
def get_sync_info(self, source_replica_uid):
"""
Returns the sync state.
Note: Doesnt return anything now. BROKEN.
"""
str_msg = serialize_msg("SourceRequest",
source_replica_uid=source_replica_uid)
str_sync_type = serialize_msg("SyncType", sync_type="sync-from")
str_zmq_verb = serialize_msg("ZMQVerb", verb=proto.ZMQVerb.GET)
@indradhanush
indradhanush / term_vs_destroy.py
Created June 16, 2014 08:20
Reproducing blocking zmq.Context.term() vs Non blocking zmq.Context.destroy()
import zmq
# Server
class Server():
def __init__(self, context):
self.context = context
self.router = self.context.socket(zmq.ROUTER)
self.router.bind("tcp://127.0.0.1:9876")
@indradhanush
indradhanush / sync.py
Created June 16, 2014 08:05
Asynchronous request response
def get_sync_info(source_id):
"""
Gets the sync information.
"""
socket.send_multipart([req_type, source_id])
# Should return the response to the above request.
# Some callback should return the response probably.
return response