mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-23 01:11:33 +00:00
Create initial version of SolvableConnector
This commit is contained in:
parent
03d6f587e9
commit
27376ada22
21
lib/tfw/networking/solvable_connector.py
Normal file
21
lib/tfw/networking/solvable_connector.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import zmq
|
||||||
|
from zmq.eventloop import ioloop
|
||||||
|
|
||||||
|
from tfw.config import CONTROLLER_PORT
|
||||||
|
from tfw.util import ZMQConnectorBase
|
||||||
|
from tfw.networking.serialization import serialize_all, deserialize_all
|
||||||
|
|
||||||
|
ioloop.install()
|
||||||
|
|
||||||
|
|
||||||
|
class SolvableConnector(ZMQConnectorBase):
|
||||||
|
def __init__(self, zmq_context=None):
|
||||||
|
super(SolvableConnector, self).__init__(zmq_context)
|
||||||
|
self._zmq_req_socket = self._zmq_context.socket(zmq.REQ)
|
||||||
|
self._zmq_req_socket.bind('tcp://*:{}'.format(CONTROLLER_PORT))
|
||||||
|
|
||||||
|
def send(self, key, message):
|
||||||
|
self._zmq_req_socket.send_multipart(serialize_all(key, message))
|
||||||
|
|
||||||
|
def recv(self):
|
||||||
|
return deserialize_all(*self._zmq_req_socket.recv_multipart())
|
Loading…
Reference in New Issue
Block a user