本文整理汇总了Python中context.Context.start方法的典型用法代码示例。如果您正苦于以下问题:Python Context.start方法的具体用法?Python Context.start怎么用?Python Context.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类context.Context
的用法示例。
在下文中一共展示了Context.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runTest
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import start [as 别名]
def runTest( self ):
context = Context( 'context' )
context.start()
listener = TestListener()
listener.context = context
node = System( 'system0', listener )
node.addListener( listener )
assert( node.currentState == 'Stopped' )
node.process( Event( 'Start' ) )
assert( node.currentState == 'Started' )
sleep( 2 )
node.process( Event( 'Pause' ) )
assert( node.currentState == 'Paused' )
node.process( Event( 'Continue' ) )
assert( node.currentState == 'Started' )
node.process( Event( 'Stop' ) )
assert( node.currentState == 'Stopped' )
示例2: runTest
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import start [as 别名]
def runTest( self ):
context = Context( 'context' )
context.start()
listener = UacSubscriptionListener()
listener.context = context
subscription = UacSubscription( 'subscription0', listener, subscriptionSource='', user='chloe', resourceUri=Uri('bones', 'cave'), event='whats-to-eat', contentType=ContentType('food', 'xml'), expires=3600 )
context.queue( Event( subscription.EVENT_SUBSCRIBE ), subscription )
s = 'SIP/2.0 100 Trying\r\nTo: "Matt"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\nCall-ID: abcd\r\n\r\n'
m = Message( s )
e = MessageEvent( MessageEvent.EVENT_RX, message=m, transport='udp', localAddress='127.0.0.1', localPort=9000, remoteAddress='127.0.0.1', remotePort=9001 )
context.queue( e, subscription )
s = 'SIP/2.0 200 OK\r\nTo: "Matt"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\nCall-ID: abcd\r\n\r\n'
m = Message( s )
e = MessageEvent( MessageEvent.EVENT_RX, message=m, transport='udp', localAddress='127.0.0.1', localPort=9000, remoteAddress='127.0.0.1', remotePort=9001 )
context.queue( e, subscription )
context.queue( Event( subscription.EVENT_UNSUBSCRIBE ), subscription )
s = 'SIP/2.0 200 OK\r\nTo: "Matt"<sip:[email protected]>\r\nContact: "RileyMan"<sip:[email protected]>\r\nFrom: "Josh"<sip:[email protected]>\r\nCall-ID: abcd\r\n\r\n'
m = Message( s )
e = MessageEvent( MessageEvent.EVENT_RX, message=m, transport='udp', localAddress='127.0.0.1', localPort=9000, remoteAddress='127.0.0.1', remotePort=9001 )
context.queue( e, subscription )
sleep( 0.5 )
assert 1
示例3: test
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import start [as 别名]
def test(self):
c = Context('Root')
c.start()
o0 = self.SampleObj()
Dispatcher.add(obj=o0, parent_obj=None, context=c)
o1 = self.SampleObj()
Dispatcher.add(obj=o1, parent_obj=None, context=c)
Dispatcher.add_listener(src_obj=o1, dst_obj=o0)
Dispatcher.send(event=Event('1'), src_obj=o0, dst_obj=o1)
assert str(o1.lastHandler) == 'on1'
Dispatcher.queue(event=Event('2'), src_obj=o0, dst_obj=o1)
#assert str(o1.lastHandler) == 'on2'
Dispatcher.send(event=Event('3'), src_obj=o0, dst_obj=o1)
#assert str(o1.lastHandler) == 'on3'
Dispatcher.notify(event=Event('4'), src_obj=o1)
#assert str(o1.lastHandler) == 'on4'
Dispatcher.notify(event=Event('4'), src_obj=o1)
#assert str(o1.lastHandler) == 'on4'
c.stop()
示例4: test
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import start [as 别名]
def test(self):
events = [Event('event0'), Event('event1'), Event('event2')]
o = SampleObj(events)
c = Context('context0')
c.start()
for event in events:
future = c.queue(event, o, o)
#print future
#future.cancel()
#print future()
#print future
time.sleep(0.1)
c.stop()
示例5: test
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import start [as 别名]
def test(self):
d = Dispatcher()
c = Context('Root')
c.start()
o = self.SampleObj()
d.add(obj=o, parent_obj=None, context=c)
o.Start()
assert str(o.state.current_state) == o.STATE_STARTED
assert str(o.last_handler) == 'inStarted_onEnter'
o.Pause()
assert str(o.state.current_state) == 'Paused'
assert str(o.last_handler) == 'inPaused_onEnter'
o.Stop()
assert str(o.state.current_state) == 'Stopped'
assert str(o.last_handler) == 'inStopped_onEnter'
c.stop()
示例6: Context
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import start [as 别名]
import logging,sys
from context import Context
from reader.dummy_reader import DummyReader
from parser.dummy_parser import DummyParser
from lister.dummy_lister import DummyLister
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(threadName)s %(levelname)s %(name)s: %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
stream=sys.stdout)
context = Context()
context.register("reader", DummyReader)
context.register("parser", DummyParser)
context.register("lister", DummyLister)
context.start("dummy://list")
print context._addedDocs