本文整理汇总了Python中smokesignal.on函数的典型用法代码示例。如果您正苦于以下问题:Python on函数的具体用法?Python on怎么用?Python on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了on函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, name, k=10):
self.k = k
self.fname = _timestamped_filename(
"%s-precision-at-%d" % (name, self.k))
smokesignal.on('evaluation_finished', self.on_evaluation_finished)
super(PrecisionAtKListener, self).__init__()
开发者ID:TythonLee,项目名称:linkpred,代码行数:7,代码来源:listeners.py
示例2: test_emit_with_callback_args
def test_emit_with_callback_args(self):
# Register first
smokesignal.on('foo', self.mock_callback)
assert smokesignal.responds_to(self.mock_callback, 'foo')
smokesignal.emit('foo', 1, 2, 3, foo='bar')
assert self.mock_callback.called_with(1, 2, 3, foo='bar')
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:7,代码来源:tests.py
示例3: test_on_creates_responds_to_fn
def test_on_creates_responds_to_fn(self):
# Registering a callback should create partials to smokesignal
# methods for later user
smokesignal.on('foo', self.callback)
assert hasattr(self.callback, 'responds_to')
assert self.callback.responds_to('foo')
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:7,代码来源:tests.py
示例4: test_clear_many
def test_clear_many(self):
smokesignal.on(('foo', 'bar', 'baz'), self.fn)
smokesignal.clear('foo', 'bar')
assert smokesignal.receivers == {
'foo': set(),
'bar': set(),
'baz': set([self.fn]),
}
开发者ID:Brightmd,项目名称:smokesignal,代码行数:8,代码来源:tests.py
示例5: test_clear_all
def test_clear_all(self):
smokesignal.on(('foo', 'bar'), self.callback)
assert len(smokesignal._receivers['foo']) == 1
assert len(smokesignal._receivers['bar']) == 1
smokesignal.clear_all()
assert len(smokesignal._receivers['foo']) == 0
assert len(smokesignal._receivers['bar']) == 0
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:8,代码来源:tests.py
示例6: test_on_creates_signals_fn
def test_on_creates_signals_fn(self):
# Registering a callback should create partials to smokesignal
# methods for later user
smokesignal.on(('foo', 'bar'), self.callback)
assert hasattr(self.callback, 'signals')
assert 'foo' in self.callback.signals()
assert 'bar' in self.callback.signals()
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:8,代码来源:tests.py
示例7: test_on_registers_many
def test_on_registers_many(self):
assert len(smokesignal._receivers['foo']) == 0
assert len(smokesignal._receivers['bar']) == 0
smokesignal.on(('foo', 'bar'), self.callback)
assert len(smokesignal._receivers['foo']) == 1
assert len(smokesignal._receivers['bar']) == 1
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:8,代码来源:tests.py
示例8: test_disconnect
def test_disconnect(self):
# Register first
smokesignal.on(('foo', 'bar'), self.callback)
assert smokesignal.responds_to(self.callback, 'foo')
assert smokesignal.responds_to(self.callback, 'bar')
smokesignal.disconnect(self.callback)
assert not smokesignal.responds_to(self.callback, 'foo')
assert not smokesignal.responds_to(self.callback, 'bar')
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:9,代码来源:tests.py
示例9: test_on_registers_many
def test_on_registers_many(self):
assert smokesignal.receivers == {}
smokesignal.on(('foo', 'bar'), self.fn)
assert smokesignal.receivers == {
'foo': set([self.fn]),
'bar': set([self.fn]),
}
开发者ID:Brightmd,项目名称:smokesignal,代码行数:9,代码来源:tests.py
示例10: __init__
def __init__(self):
if not hasattr(self, 'plugins'):
self.plugins = {}
if not hasattr(self, 'enabled_plugins'):
# Enabled plugins is a dict: channel -> set()
self.enabled_plugins = defaultdict(lambda: set(getattr(settings, 'ENABLED_PLUGINS', [])))
smokesignal.on('started', self.load)
开发者ID:michaelorr,项目名称:helga,代码行数:9,代码来源:core.py
示例11: test_on_decorator_max_calls_as_arg
def test_on_decorator_max_calls_as_arg(self):
# Register first - like a decorator
smokesignal.on('foo', 3)(self.fn)
# Call a bunch of times
for x in range(10):
smokesignal.emit('foo')
assert self.fn.call_count == 3
开发者ID:Brightmd,项目名称:smokesignal,代码行数:9,代码来源:tests.py
示例12: test_disconnect_from_removes_all
def test_disconnect_from_removes_all(self):
# Register first
smokesignal.on(('foo', 'bar'), self.callback)
assert smokesignal.responds_to(self.callback, 'foo')
assert smokesignal.responds_to(self.callback, 'bar')
# Remove it
smokesignal.disconnect_from(self.callback, ('foo', 'bar'))
assert not smokesignal.responds_to(self.callback, 'foo')
assert not smokesignal.responds_to(self.callback, 'bar')
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:10,代码来源:tests.py
示例13: test_on_max_calls
def test_on_max_calls(self):
# Register first
smokesignal.on('foo', self.fn, max_calls=3)
# Call a bunch of times
for x in range(10):
smokesignal.emit('foo')
assert self.fn.call_count == 3
assert smokesignal.receivers['foo'] == set()
开发者ID:Brightmd,项目名称:smokesignal,代码行数:10,代码来源:tests.py
示例14: test_disconnect_from_removes_only_one
def test_disconnect_from_removes_only_one(self):
# Register first
smokesignal.on(('foo', 'bar'), self.fn)
assert smokesignal.responds_to(self.fn, 'foo')
assert smokesignal.responds_to(self.fn, 'bar')
# Remove it
smokesignal.disconnect_from(self.fn, 'foo')
assert not smokesignal.responds_to(self.fn, 'foo')
assert smokesignal.responds_to(self.fn, 'bar')
开发者ID:Brightmd,项目名称:smokesignal,代码行数:10,代码来源:tests.py
示例15: __init__
def __init__(self):
# Preferred way
smokesignal.on('foo', self.foo)
# Old way
@smokesignal.on('foo')
def _bar():
self.bar()
self.foo_count = 0
self.bar_count = 0
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:11,代码来源:tests.py
示例16: test_clear_all
def test_clear_all(self):
smokesignal.on(('foo', 'bar'), self.fn)
assert smokesignal.receivers == {
'foo': set([self.fn]),
'bar': set([self.fn]),
}
smokesignal.clear_all()
assert smokesignal.receivers == {
'foo': set(),
'bar': set(),
}
开发者ID:Brightmd,项目名称:smokesignal,代码行数:12,代码来源:tests.py
示例17: onJoin
def onJoin(self, details):
# TEMP: ping the server, let it know we just came up
# yield self.call('pd', 'routerConnected', self._session_id)
yield self.register(self.ping, 'ping')
yield self.register(self.update, 'update')
# yield self.register(self.logsFromTime, 'logsFromTime')
yield self.register(self.getConfig, 'getConfig')
yield self.register(self.setConfig, 'setConfig')
# route output to the logs call
smokesignal.on('logs', self.logs)
yield cxbr.BaseSession.onJoin(self, details)
开发者ID:SejalChauhan,项目名称:Paradrop,代码行数:14,代码来源:apiinternal.py
示例18: test_on_decorator_max_calls
def test_on_decorator_max_calls(self):
# Make a method that has a call count
def cb():
cb.call_count += 1
cb.call_count = 0
# Register first - like a cecorator
smokesignal.on('foo', max_calls=3)(cb)
assert len(smokesignal._receivers['foo']) == 1
# Call a bunch of times
for x in range(10):
smokesignal.emit('foo')
assert cb.call_count == 3
开发者ID:JamesHyunKim,项目名称:smokesignal,代码行数:15,代码来源:tests.py
示例19: __init__
def __init__(self):
if not hasattr(self, 'plugins'):
self.plugins = {}
self.plugin_names = set(ep.name for ep in pkg_resources.iter_entry_points('helga_plugins'))
# Plugins whitelist/blacklist
self.whitelist_plugins = self._create_plugin_list('ENABLED_PLUGINS', default=True)
self.blacklist_plugins = self._create_plugin_list('DISABLED_PLUGINS', default=set())
# Figure out default channel plugins using the whitelist and blacklist
default = self._create_plugin_list('DEFAULT_CHANNEL_PLUGINS', default=set())
# Make sure to exclude extras
self.default_channel_plugins = (default & self.whitelist_plugins) - self.blacklist_plugins
if not hasattr(self, 'enabled_plugins'):
# Enabled plugins is a dict: channel -> set()
self.enabled_plugins = defaultdict(lambda: self.default_channel_plugins)
smokesignal.on('started', self.load)
开发者ID:alfredodeza,项目名称:helga,代码行数:21,代码来源:__init__.py
示例20: test_max_calls
def test_max_calls(self):
"""
Do I decrement _max_calls immediately when the function is called,
even when I'm passing through a reactor loop?
Discussion: In a naive implementation, max_calls was handled when the
function was called, but we use maybeDeferred, which passes the call
through a reactor loop.
max_calls needs to be decremented before it passes through the
reactor, lest we call it multiple times per loop because the decrement
hasn't happened yet.
"""
def cb():
return 19
smokesignal.on('19', cb, max_calls=19)
d1 = smokesignal.emit('19')
assert list(smokesignal.receivers['19'])[0]._max_calls == 18
d2 = smokesignal.emit('19')
assert list(smokesignal.receivers['19'])[0]._max_calls == 17
return defer.DeferredList([d1, d2])
开发者ID:Brightmd,项目名称:smokesignal,代码行数:22,代码来源:tests_twisted.py
注:本文中的smokesignal.on函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论