Skip to content

Commit dee715a

Browse files
committed
fix OMCSessionBase - the variables self.readonly and self.omc_cache are needed here
1 parent 2981831 commit dee715a

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

OMPython/__init__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ def wait(self, timeout):
9999

100100
class OMCSessionBase(metaclass=abc.ABCMeta):
101101

102+
def __init__(self, readonly=False):
103+
self._readonly = readonly
104+
self._omc_cache = {}
105+
102106
def clearOMParserResult(self):
103107
OMParser.result = {}
104108

@@ -126,10 +130,10 @@ def sendExpression(self, command, parsed=True):
126130
def ask(self, question, opt=None, parsed=True):
127131
p = (question, opt, parsed)
128132

129-
if self.readonly and question != 'getErrorString':
133+
if self._readonly and question != 'getErrorString':
130134
# can use cache if readonly
131-
if p in self.omc_cache:
132-
return self.omc_cache[p]
135+
if p in self._omc_cache:
136+
return self._omc_cache[p]
133137

134138
if opt:
135139
expression = '{0}({1})'.format(question, opt)
@@ -145,7 +149,7 @@ def ask(self, question, opt=None, parsed=True):
145149
raise e
146150

147151
# save response
148-
self.omc_cache[p] = res
152+
self._omc_cache[p] = res
149153

150154
return res
151155

@@ -331,10 +335,10 @@ def __init__(self, readonly=False, timeout=10.00,
331335
if dockerExtraArgs is None:
332336
dockerExtraArgs = []
333337

338+
super().__init__(readonly=readonly)
339+
334340
self.omhome = self._get_omhome(omhome=omhome)
335341

336-
self.readonly = readonly
337-
self.omc_cache = {}
338342
self._omc_process = None
339343
self._omc_command = None
340344
self._omc = None

0 commit comments

Comments
 (0)