Ejemplo n.º 1
0
 def test_get_blocking(self):
     import thread
     result = []
     def getitem(mq, sessid):
         result.append(mq.get(sessid))
     mq = MultiQueue()
     thread.start_new_thread(getitem, (mq, 1234))
     assert not result
     mq.put(1)
     py.std.time.sleep(0.1)
     assert result == [1]
Ejemplo n.º 2
0
 def test_get_two_sessid(self):
     mq = MultiQueue()
     mq.put(1)
     result = mq.get(1234)
     assert result == 1
     mq.put(2)
     result = mq.get(1234)
     assert result == 2
     result = mq.get(5678)
     assert result == 1
     result = mq.get(5678)
     assert result == 2
Ejemplo n.º 3
0
 def test_empty(self):
     mq = MultiQueue()
     assert mq.empty()
     mq.put(1)
     assert not mq.empty()
     result = mq.get(1234)
     result == 1
     assert mq.empty()
     mq.put(2)
     result = mq.get(4567)
     assert result == 1
     result = mq.get(1234)
     assert result == 2
     assert not mq.empty()
     result = mq.get(4567)
     assert result == 2
     assert mq.empty()
Ejemplo n.º 4
0
 def test_get_one_sessid(self):
     mq = MultiQueue()
     mq.put(1)
     result = mq.get(1234)
     assert result == 1