Пример #1
0
 def testTimeout(self):
     t0 = time.time()
     c = channels.Channel("test", timeout=0)
     self.assertTrue(time.time() - t0 < 0.02)
     t0 = time.time()
     c = channels.Channel("test", timeout=2)
     self.assertTrue(time.time() - t0 >= 2)
     self.assertEquals(c.value, channels.NotInitialized())
Пример #2
0
 def testExtChannel(self):
     p1 = test_ext_channel(2, "test", "hello")
     time.sleep(1)  # wait for process to be started
     c = channels.Channel("test")
     p1_output = p1.stderr.readline().split('\n')[0]
     self.assertEquals(c.value, p1_output, 'hello')
     c.value = 5
     p1_output = p1.stderr.readline().split('\n')[0]
     self.assertEquals(p1_output, '5')
     p1.wait()
Пример #3
0
import os
import time
from beacon import channels
import sys
import gevent

args = [arg for arg in sys.argv[2:] if not '=' in arg]
kwargs = dict([kwarg.split("=") for kwarg in sys.argv[2:] if '=' in kwarg])
for kw in kwargs.keys():
    value = kwargs[kw]
    try:
        value = float(value)
    except:
        try:
            value = int(value)
        except:
            try:
                value = bool(value)
            except:
                pass
    kwargs[kw] = value

c = channels.Channel(*args, **kwargs)
sys.stderr.write("%s\n" % c.value)
gevent.sleep(int(sys.argv[1]))
sys.stderr.write("%s\n" % c.value)
Пример #4
0
 def testSetChannel(self):
     c = channels.Channel("test", "test")
     self.assertEquals(c.value, 'test')
Пример #5
0
 def testNotInitialized(self):
     c = channels.Channel("test")
     self.assertEquals(c.value, channels.NotInitialized())