Exemplo n.º 1
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:
Exemplo n.º 2
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
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
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