diff --git a/idl/mdsconnect.pro b/idl/mdsconnect.pro index 77e5fea488..f62c0d1cb5 100644 --- a/idl/mdsconnect.pro +++ b/idl/mdsconnect.pro @@ -153,8 +153,12 @@ end pro mdsconnect,host,status=status,quiet=quiet,port=port,socket=socket on_error,2 - if (not keyword_set(socket)) then $ - mdsdisconnect,/quiet + ; if (not keyword_set(socket)) then $ + ; mdsdisconnect,/quiet + defsysv, "!MDS_SOCKET", exists=has_mds_socket + if (not has_mds_socket) then begin + defsysv, "!MDS_SOCKET", -1 + endif if n_elements(port) ne 0 then begin setenv_,'mdsip='+strtrim(port,2) endif else if getenv('mdsip') eq '' then begin diff --git a/idl/mdsisclient.pro b/idl/mdsisclient.pro index 198d2a303d..e1fad85085 100644 --- a/idl/mdsisclient.pro +++ b/idl/mdsisclient.pro @@ -1,5 +1,5 @@ function mdsisclient,socket=socket -if (keyword_set(socket)) then $ +if (keyword_set(socket)) then $ ; Fails if socket = 0 (see issue 2625) if (socket ge 0) then $ return, 1 $ else $ diff --git a/idl/set_database.pro b/idl/set_database.pro index ee4a16c41f..4c96c7d6f4 100644 --- a/idl/set_database.pro +++ b/idl/set_database.pro @@ -438,7 +438,26 @@ pro set_database, dbname, status=status, quiet=quiet,debug=debug, reset=reset, f status = dbinfo(dbname, mdshost, host, name, user, pass, reset=reset, file=file) if (status eq 0) then $ return - MDSDbconnect, mdshost + + ; For issue 2625, must ensure connection ID is greater than zero. + ; Most robust solution is to open an extraneous connection if needed. + ; Don't disconnect because resets !MDS_SOCKET to -1 (triggers 2625). + defsysv, "!MDS_SOCKET", exists=has_mds_socket + if (not has_mds_socket) then begin + mdsconnect, mdshost + endif + + ; The global !MDS_SOCKET should now definitely exist. + if (!MDS_SOCKET lt 0) then begin + if not (keyword_set(quiet)) then begin + Message, "Error connecting to MDSplus host "+mdshost, /continue + endif else begin + Message, "Error connecting to MDSplus host "+mdshost, /continue, /noprint + endelse + return + endif + + MDSDbconnect, mdshost ; increments the socket status = mdsvalue("dblogin($, $, $)", host, user, pass, socket=!MDSDB_SOCKET) if (not status) then begin if not (keyword_set(quiet)) then begin diff --git a/python/MDSplus/connection.py b/python/MDSplus/connection.py index 4e4c367bc1..8599ccf9cd 100644 --- a/python/MDSplus/connection.py +++ b/python/MDSplus/connection.py @@ -205,16 +205,12 @@ def get(self, exp, *args, **kwargs): args = kwargs['arglist'] timeout = kwargs.get('timeout', -1) num = len(args)+1 - - exp = 'serializeout(`('+exp+'))' - exp = _ver.tobytes(exp) _exc.checkStatus(_SendArg(self.conid, 0, 14, num, len(exp), 0, 0, ctypes.c_char_p(exp))) for i, arg in enumerate(args): self._send_arg(arg, i+1, num) - retSerialized = self._get_answer(timeout) - return retSerialized.deserialize() + return self._get_answer(timeout) class Connection(object):