def get_queue(qid=None): r"""Create or return a sysv_ipc.MessageQueue and register it. Args: qid (int, optional): If provided, ID for existing queue that should be returned. Defaults to None and a new queue is returned. Returns: :class:`sysv_ipc.MessageQueue`: Message queue. """ if _ipc_installed: kwargs = dict(max_message_size=tools.get_CIS_MSG_MAX()) if qid is None: kwargs['flags'] = sysv_ipc.IPC_CREX mq = sysv_ipc.MessageQueue(qid, **kwargs) key = str(mq.key) CommBase.register_comm('IPCComm', key, mq) return mq else: # pragma: windows logging.warning("IPC not installed. Queue cannot be returned.") return None
import os import numpy as np import nose.tools as nt import unittest from cis_interface.interface import PsiInterface from cis_interface.tools import CIS_MSG_EOF, get_CIS_MSG_MAX, CIS_MSG_BUF from cis_interface.drivers import ( import_driver, InputCommDriver, OutputCommDriver, MatlabModelDriver) from cis_interface.tests import CisTestClassInfo CIS_MSG_MAX = get_CIS_MSG_MAX() def test_maxMsgSize(): r"""Test max message size.""" nt.assert_equal(PsiInterface.maxMsgSize(), CIS_MSG_MAX) def test_eof_msg(): r"""Test eof message signal.""" nt.assert_equal(PsiInterface.eof_msg(), CIS_MSG_EOF) def test_bufMsgSize(): r"""Test buf message size.""" nt.assert_equal(PsiInterface.bufMsgSize(), CIS_MSG_BUF) @unittest.skipIf(not MatlabModelDriver._matlab_installed, "Matlab not installed.") def test_PsiMatlab_class(): # pragma: matlab
def maxMsgSize(self): r"""int: Maximum message size.""" return get_CIS_MSG_MAX()