Exemple #1
0
 def testNonBlockingGet(self):
     self.namespace = self._createInterface()
     iface = PyRQIface(ref="testNonBlockingGet", namespace=self.namespace, quiet=self.quiet, loggingModule=testLoggingModule)
     try:
         _data = iface.get(block=False, timeout=None)
     except Empty, _e:
         assert True
Exemple #2
0
 def testPutTimesout(self, eData="hello world!", noCheck=False, block=True):
     namespace = self._createInterface()
     try:
         iface = PyRQIface(namespace=namespace, ref="testPutTimesout-put", quiet=self.quiet, loggingModule=testLoggingModule)
         iface.put(eData, block=block, timeout=0.1)
     except Full, _e:
         assert True
Exemple #3
0
 def testPostCloseDifferentIface(self, eData="hello.world!", block=True, timeout=None):
     self.testCreate()
     self.iface.close(timeout=100000)
     #    Now attempt a PUT:
     iface = PyRQIface(ref="testPostCloseDifferentIface.0", namespace=self.namespace, quiet=self.quiet, loggingModule=testLoggingModule)
     try:
         iface.put(eData, block=block, timeout=timeout)
     except ClosedError, _e:
         assert True
Exemple #4
0
 def doPut(initialDelay, ref, putTimeout, data):
     time.sleep(initialDelay)
     iface = PyRQIface(ref="put.%(R)s"%{"R":ref}, namespace=namespace, quiet=self.quiet, loggingModule=testLoggingModule)
     while self.timerTerminate==0 and len(data)>0:
         (delay, eData) = data.pop(0)
         time.sleep(delay)
         try:
             iface.put(data=eData, timeout=putTimeout)
         except Full, eData:
             pass
         with l:
             ePuts.append(eData)
Exemple #5
0
        def doGet(initialDelay, ref, getTimeout):
            time.sleep(initialDelay)
            self.logger.debug("GET %(R)s START"%{"R":ref})
            iface = PyRQIface(namespace=self.namespace, quiet=self.quiet, ref="get.%(R)s"%{"R":ref}, loggingModule=testLoggingModule)
            while self.timerTerminate==0:
                try:
                    data = iface.get(block=True, timeout=min(1, min(1, getTimeout)))
                except Empty, data:
                    continue
                except Exception, _e:
#                    self.logger.error("GET %(R)s EXCEPTION: %(E)s"%{"R":ref, "E":_e})
                    continue
Exemple #6
0
 def doGet(initialDelay, ref, getTimeout):
     time.sleep(initialDelay)
     iface = PyRQIface(ref="get.%(R)s"%{"R":ref}, namespace=namespace, quiet=self.quiet, loggingModule=testLoggingModule)
     while self.timerTerminate==0:
         rtn = False
         try:
             data = iface.get(timeout=getTimeout)
         except Empty, data:
             rtn = True
         with l:
             eGets.append(data)
         if rtn:
             return
Exemple #7
0
 def testCreateTimesout(self, timeout=1):
     r"""
     @deprecated: Timeout's don't work!
     """
     #    Create a new queue and get it's namespace:
     iface = PyRQIface(ref="testCreateTimesout", quiet=self.quiet, loggingModule=testLoggingModule)
     latency = iface._minimumSocketLatency
     iface._minimumSocketLatency = 0
     try:
         try:
             iface.create(timeout=timeout)
         except PyRQError, _e:
             assert True
         else:
Exemple #8
0
 def testDelayedGetWithTimeoutThenClosed(self, maxsize=1):
     r"""
     @summary: Test what happens to a q.get(block=True, timeout=lots)
     when the socket is remotely closed.
     """
     iface = PyRQIface(quiet=self.quiet, ref="creator-testDelayedGetWithTimeoutThenClosed")
     namespace = iface.create(maxsize=maxsize)
     self._closeQueue(namespace, delay=1, name="closer-testDelayedGetWithTimeoutThenClosed")
     iface = PyRQIface(namespace=namespace, quiet=self.quiet, ref="testDelayedGetWithTimeoutThenClosed")
     try:
         iface.get(block=True, timeout=10)
     except (ClosedError, Empty):
         assert True
     else:
         assert False
Exemple #9
0
 def setUp(self):
     self.logger = self._getLogger()
     self.quiet=True
     self.random = Random()
     self.timerTerminate = 0
     self._timers = []
     self.namespaces = []
     self.dummyQueue = Queue()
     self.iface = PyRQIface(ref="test", quiet=self.quiet, loggingModule=testLoggingModule)
     self.marshaller = MarshallerFactory.get(MarshallerFactory.DEFAULT, quiet=self.quiet)
     desiredPort = "19001"
     self.r = SubprocessQueueServer(
                                    desiredPort=desiredPort,
                                    handlerClazz=Linkage.create(TimeoutMockHandler),
                                    quiet=self.quiet,
        )
     PyRQIface.setGlobalPYRQ(self.r.details())
Exemple #10
0
    def setUp(self):
        self.quiet=True
        self.random = Random()
        self._timers = []
        self.namespaces = []
        self.iface = PyRQIface(quiet=self.quiet, ref="test")
        self.dummyQueue = Queue()
        self.marshaller = MarshallerFactory.get(MarshallerFactory.DEFAULT, quiet=self.quiet)
        desiredPort = "19001"
        self.r = SubprocessQueueServer(
                                       desiredPort=desiredPort,
                                       handlerClazz=Linkage.create(MockHandler),
                                       quiet=self.quiet
#           includePydevd="/home/francis/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/org.python.pydev.debug_2.5.0.2012040618/pysrc"
           )
        PyRQIface.setGlobalPYRQ(self.r.details())
        self.r.start().waitUntilRunning()
        pass
Exemple #11
0
 def testPutOnFullQueueWithTimeout(self, maxsize=1):
     #    Put 2 items, second one should block forever, then we close the q.
     iface = PyRQIface(quiet=self.quiet, ref="creator-testDelayedWithTimeoutPutThenClosed")
     namespace = iface.create(maxsize=maxsize)
     iface = PyRQIface(namespace=namespace, quiet=self.quiet, ref="testDelayedWithTimeoutPutThenClosed")
     iface.put("hello.world.1", block=True, timeout=None)
     #    Queue should now be full.
     try:
         iface.put("hello.world.2", block=True, timeout=2)
     except Full, _e:
         assert True
Exemple #12
0
 def testDelayedWithTimeoutPutThenClosed(self, maxsize=1):
     #    Put 2 items, second one should block forever, then we close the q.
     iface = PyRQIface(quiet=self.quiet, ref="creator-testDelayedWithTimeoutPutThenClosed")
     namespace = iface.create(maxsize=maxsize)
     iface = PyRQIface(namespace=namespace, quiet=self.quiet, ref="testDelayedWithTimeoutPutThenClosed")
     iface.put("hello.world.1", block=True, timeout=None)
     #    Queue should now be full.
     self._closeQueue(namespace, delay=2, name="closer-testDelayedWithTimeoutPutThenClosed")
     try:
         iface.put("hello.world.2", block=True, timeout=5)
     except (ClosedError, Full):
         assert True
     else:
         assert False
Exemple #13
0
class TestWithTimeouts(_BaseReader):
    def setUp(self):
        self.logger = self._getLogger()
        self.quiet=True
        self.random = Random()
        self.timerTerminate = 0
        self._timers = []
        self.namespaces = []
        self.dummyQueue = Queue()
        self.iface = PyRQIface(ref="test", quiet=self.quiet, loggingModule=testLoggingModule)
        self.marshaller = MarshallerFactory.get(MarshallerFactory.DEFAULT, quiet=self.quiet)
        desiredPort = "19001"
        self.r = SubprocessQueueServer(
                                       desiredPort=desiredPort,
                                       handlerClazz=Linkage.create(TimeoutMockHandler),
                                       quiet=self.quiet,
           )
        PyRQIface.setGlobalPYRQ(self.r.details())
    def _createInterface(self):
        namespace = self.iface.create()
        self.iface = PyRQIface(namespace=namespace, ref="test", quiet=self.quiet, loggingModule=testLoggingModule)
        self.namespaces.append(namespace)
        return namespace
    def tearDown(self):
        self.timerTerminate = 1
        time.sleep(2)
        try:
            self.dummyQueue.close()
            del self.dummyQueue
        except Exception, _e:
            pass
        for namespace in self.namespaces:
            self.iface.setNamespace(namespace)
        try:    self.iface.close()
        except ClosedError, _e:
            pass
Exemple #14
0
 def _createInterface(self):
     namespace = self.iface.create()
     self.iface = PyRQIface(namespace=namespace, ref="test", quiet=self.quiet, loggingModule=testLoggingModule)
     self.namespaces.append(namespace)
     return namespace
Exemple #15
0
 def close(namespace):
     iface = PyRQIface(ref="testCloseDuringGet", namespace=namespace, quiet=self.quiet, loggingModule=testLoggingModule)
     iface.close()
Exemple #16
0
 def testPostCloseDifferentIface(self, eData="hello.world!", block=True, timeout=None):
     self.testCreate()
     self.iface.close(timeout=100000)
     #    Now attempt a PUT:
     iface = PyRQIface(ref="testPostCloseDifferentIface.0", namespace=self.namespace, quiet=self.quiet, loggingModule=testLoggingModule)
     try:
         iface.put(eData, block=block, timeout=timeout)
     except ClosedError, _e:
         assert True
     else:
         assert False
     finally:
         try:    iface.close()
         except: pass
     #    Now attempt a GET:
     iface = PyRQIface(ref="testPostCloseDifferentIface.1", namespace=self.namespace, quiet=self.quiet, loggingModule=testLoggingModule)
     try:
         iface.get(block=block, timeout=timeout)
     except ClosedError, _e:
         assert True
     else:
         assert False
     finally:
         try:    iface.close()
         except: pass
 def testCloseDuringGet(self):
     self.testCreate()
     def close(namespace):
         iface = PyRQIface(ref="testCloseDuringGet", namespace=namespace, quiet=self.quiet, loggingModule=testLoggingModule)
         iface.close()
     threading.Timer(0, close, args=[self.namespace]).start()