Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close zeromq context and socket. #1123

Merged
merged 1 commit into from
Sep 28, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/ansible/runner/connection_plugins/fireball.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, runner, host, port=None):

self.host = host
self.key = utils.key_for_hostname(host)
self.context = None
self.socket = None
# port passed in is the SSH port, which we ignore
self.port = constants.ZEROMQ_PORT
Expand All @@ -54,8 +55,8 @@ def connect(self):
raise errors.AnsibleError("zmq is not installed")

# this is rough/temporary and will likely be optimized later ...
context = zmq.Context()
socket = context.socket(zmq.REQ)
self.context = zmq.Context()
socket = self.context.socket(zmq.REQ)
addr = "tcp://%s:%s" % (self.host, self.port)
socket.connect(addr)
self.socket = socket
Expand Down Expand Up @@ -125,5 +126,10 @@ def fetch_file(self, in_path, out_path):

def close(self):
''' terminate the connection '''
# no need for this
# Be a good citizen
try:
self.socket.close()
self.context.term()
except:
pass