Skip to content

Commit

Permalink
zmq: use global client context
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Mar 21, 2019
1 parent 3c0ffb5 commit 80d7d8a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/cylc/network/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
SuiteSrvFilesManager, SuiteServiceFileError)


# we should only have one ZMQ context per-process
CONTEXT = zmq.asyncio.Context()


class ClientError(Exception):
# TODO: this is a bit messy, lets tidy
# TODO: ServerError class
Expand Down Expand Up @@ -112,8 +116,7 @@ def __init__(self, host, port, encode_method, decode_method, secret_method,
self.timeout_handler = timeout_handler

# open the ZMQ socket
self.context = zmq.asyncio.Context()
self.socket = self.context.socket(zmq.REQ)
self.socket = CONTEXT.socket(zmq.REQ)
self.socket.connect('tcp://%s:%d' % (host, port))
# if there is no server don't keep the client hanging around
self.socket.setsockopt(zmq.LINGER, int(self.DEFAULT_TIMEOUT))
Expand Down

0 comments on commit 80d7d8a

Please sign in to comment.