Skip to content

Commit

Permalink
python.Connection, removed to local for a conn
Browse files Browse the repository at this point in the history
  • Loading branch information
zack-vii committed May 19, 2021
1 parent e5ee2d1 commit ad94040
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions python/MDSplus/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MdsIpException(_exc.MDSplusException):


INVALID_CONNECTION_ID = -1
class _ConnectionLocal:
class _Connection:

_conid = INVALID_CONNECTION_ID

Expand Down Expand Up @@ -215,26 +215,26 @@ class Connection(object):
"""Implements an MDSip connection to an MDSplus server"""

@property
def local(self):
def conn(self):
try:
local = self._local.local
conn = self._local.conn
except AttributeError:
local = self._local.local = _ConnectionLocal(self.hostspec)
return local
conn = self._local.conn = _Connection(self.hostspec)
return conn

@local.deleter
def local(self):
@conn.deleter
def conn(self):
try:
local = self._local.local
conn = self._local.conn
except AttributeError:
pass
else:
del(self._local.local)
local.disconnect()
del(self._local.conn)
conn.disconnect()

def __enter__(self):
""" Used for with statement. """
self.local.__enter__()
self.conn.__enter__()
return self

def __exit__(self, type, value, traceback):
Expand All @@ -247,10 +247,10 @@ def __init__(self, hostspec):
self.connect()

def connect(self):
self.local.connect()
self.conn.connect()

def disconnect(self):
del(self.local)
del(self.conn)

def reconnect(self):
self.disconnect()
Expand Down Expand Up @@ -314,7 +314,7 @@ def get(self, exp, *args, **kwargs):
@return: result of evaluating the expression on the remote server
@rtype: Scalar or Array
"""
return self.local.get(exp, *args, **kwargs)
return self.conn.get(exp, *args, **kwargs)

def getObject(self, exp, *args, **kwargs):
return self.get('serializeout(`(%s;))' % exp, *args, **kwargs).deserialize()
Expand Down

0 comments on commit ad94040

Please sign in to comment.