Python blinker.Signal() Examples
The following are 30
code examples of blinker.Signal().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
blinker
, or try the search function
.
Example #1
Source File: GraphBase.py From PyFlow with Apache License 2.0 | 6 votes |
def __init__(self, name, manager, parentGraph=None, category='', uid=None, *args, **kwargs): super(GraphBase, self).__init__(*args, **kwargs) self.graphManager = manager self._isRoot = False self.nameChanged = Signal(str) self.categoryChanged = Signal(str) self.__name = name self.__category = category self._parentGraph = None self.childGraphs = set() self.parentGraph = parentGraph self._nodes = {} self._vars = {} self.uid = uuid.uuid4() if uid is None else uid manager.add(self)
Example #2
Source File: janus.py From AstroBox with GNU Affero General Public License v3.0 | 6 votes |
def __init__(self, url, secret=None, cxn_cls=Connection, **kwargs): self.url = url self.secret = secret self.state = self.DISCONNECTED self.cxn_cls = cxn_cls self.cxn = None self.cxn_kwargs = kwargs self.cxns = 0 self.created = threading.Event() self.plugins = [] self.plugin_idx = {} self.txns = {} self.txn_q = [] self._connected = None self._disconnected = None self._created = None # Signal fired when `Session` has been connected.
Example #3
Source File: observer.py From FF.PyAdmin with BSD 3-Clause "New" or "Revised" License | 6 votes |
def add(self, signal_name, receiver, sender=ANY): """ 增加订阅者 e.g.:: def callback_function_for_app(sender, **kwargs): pass def callback_function_for_all(sender, **kwargs): pass my_signal = signal('test') observer.add(my_signal, callback_function_for_app, 'APP') observer.add(my_signal, callback_function_for_all) :param signal_name: 订阅的主题, 信号 :param receiver: 订阅者回调方法 :param sender: ANY, 'ANY' 面向所有发布者(默认), 'APP', current_app._get_current_object() 当前 APP :return: """ if isinstance(signal_name, Signal) and hasattr(receiver, '__call__'): self._observers.append({ 'signal_name': signal_name, 'receiver': receiver, 'sender': sender, })
Example #4
Source File: AnyPin.py From PyFlow with Apache License 2.0 | 6 votes |
def __init__(self, name, owningNode, direction, **kwargs): """ :param name: Pin name :type name: string :param owningNode: Owning Node :type owningNode: :py:class:`PyFlow.Core.NodeBase.NodeBase` :param direction: PinDirection , can be input or output :type direction: :py:class:`PyFlow.Core.Common.PinDirection` """ super(AnyPin, self).__init__(name, owningNode, direction, **kwargs) self.typeChanged = Signal(str) self.dataTypeBeenSet = Signal() self.setDefaultValue(None) self._isAny = True # if True, setType and setDefault will work only once self.singleInit = False self.checkForErrors = True self.enableOptions(PinOptions.ChangeTypeOnConnection) self._defaultSupportedDataTypes = self._supportedDataTypes = tuple([pin.__name__ for pin in getAllPinClasses() if pin.IsValuePin()]) self.canChange = True self._super = None self.prevDataType = None self._lastError2 = None
Example #5
Source File: rpc.py From stig with GNU General Public License v3.0 | 6 votes |
def __init__(self, host='localhost', port=9091, *, tls=False, user='', password='', path='/transmission/rpc', enabled=True): self.host = host self.port = port self.path = path self.tls = tls self.user = user self.password = password self._headers = {'content-type': 'application/json'} self._session = None self._enabled_event = asyncio.Event() self.enabled = enabled self._request_lock = asyncio.Lock() self._connecting_lock = asyncio.Lock() self._connection_tested = False self._connection_exception = None self._timeout = TIMEOUT self._version = None self._rpcversion = None self._rpcversionmin = None self._on_connecting = Signal() self._on_connected = Signal() self._on_disconnected = Signal() self._on_error = Signal()
Example #6
Source File: api_status.py From stig with GNU General Public License v3.0 | 6 votes |
def __init__(self, srvapi, interval=1): self._session_stats_updated = False self._tcounts_updated = False self._reset_session_stats() self._reset_tcounts() self._on_update = blinker.Signal() self._poller_stats = RequestPoller(srvapi.rpc.session_stats, interval=interval) self._poller_stats.on_response(self._handle_session_stats) self._poller_stats.on_error(lambda e: log.debug('Ignoring exception: %r', e), autoremove=False) # 'session-stats' provides some counters, but not enough, so we # request a minimalistic torrent list. self._poller_tcount = RequestPoller(srvapi.torrent.torrents, keys=('rate-down', 'rate-up', 'status'), interval=interval) self._poller_tcount.on_response(self._handle_torrent_list)
Example #7
Source File: rpc.py From stig with GNU General Public License v3.0 | 6 votes |
def on(self, signal, callback, autoremove=True): """ Register `callback` for `signal` signal: 'connecting', 'connected', 'disconnected' or 'error' callback: a callable that receives this instance as a positional argument and, in case of the 'error' signal, the exception as a keyword argument with the name 'error' Callbacks are automatically unsubscribed when they are garbage-collected. """ try: sig = getattr(self, '_on_' + signal) except AttributeError: raise ValueError('Unknown signal: {!r}'.format(signal)) else: if not isinstance(sig, Signal): raise ValueError('Unknown signal: {!r}'.format(signal)) else: log.debug('Registering %r for %r event', callback, signal) sig.connect(callback, weak=autoremove)
Example #8
Source File: poll.py From stig with GNU General Public License v3.0 | 5 votes |
def __init__(self, request, *args, interval=1, **kwargs): self._on_response = blinker.Signal() self._on_error = blinker.Signal() self._prev_error = None self._interval = interval self._poll_task = None self._poll_loop_task = None self._sleep = SleepUneasy() self._skip_ongoing_request = False self._debug_info = {'request': 'No request specified yet', 'update_cbs': [], 'error_cbs': []} self.set_request(request, *args, **kwargs)
Example #9
Source File: nsqd.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_message(self): """Emitted when a message frame is received. The signal sender is the connection and the ``message`` is sent as an argument. """ return blinker.Signal(doc='Emitted when a message frame is received.')
Example #10
Source File: janus.py From AstroBox with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self, url, *args, **kwargs): self.url = url self.cli = self.client_type(url)(self, url, *args, **kwargs) # Signal fired when `Connection` has been established.
Example #11
Source File: keymap.py From stig with GNU General Public License v3.0 | 5 votes |
def __init__(self, callback=None): self._default_callback = callback self._actions = {self.DEFAULT_CONTEXT: {}} self._descriptions = {} self._bindunbind_callbacks = blinker.Signal() self._keychain_callbacks = blinker.Signal() self._keychain_partial = [] self._keychain_context = self.NO_CONTEXT
Example #12
Source File: base.py From stig with GNU General Public License v3.0 | 5 votes |
def __init__(self, path_getters, rpc, settings): self._path_getters = tuple(path_getters) self._rpc = rpc self._on_update = blinker.Signal() self._info = defaultdict(lambda: SimpleNamespace(path=None, free=None, error=None)) settings.on_update(self._gather_info_wrapper)
Example #13
Source File: consumer.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_close(self): """Emitted after :meth:`close`. The signal sender is the consumer. """ return blinker.Signal(doc='Emitted after the consumer is closed.')
Example #14
Source File: settings.py From stig with GNU General Public License v3.0 | 5 votes |
def __init__(self): self._defaults = {} self._values = {} self._constructors = {} self._getters = defaultdict(lambda: None) self._setters = defaultdict(lambda: None) self._descriptions = {} self._signals = defaultdict(lambda: Signal()) self._global_signal = Signal()
Example #15
Source File: compound.py From PyFlow with Apache License 2.0 | 5 votes |
def __init__(self, name): super(compound, self).__init__(name) self.isCompoundNode = True self.pinExposed = Signal(object) self._rawGraph = None self._rawGraphJson = None self.__inputsMap = {} self.__outputsMap = {} self.bCacheEnabled = True
Example #16
Source File: imageDisplay.py From PyFlow with Apache License 2.0 | 5 votes |
def __init__(self, name): super(imageDisplay, self).__init__(name) self.loadImage = Signal(str) self.inExec = self.createInputPin(DEFAULT_IN_EXEC_NAME, 'ExecPin', None, self.compute) self.entity = self.createInputPin('path', 'StringPin') self.outExec = self.createOutputPin(DEFAULT_OUT_EXEC_NAME, 'ExecPin', None) self.failed = self.createOutputPin("failed", 'ExecPin', None)
Example #17
Source File: Variable.py From PyFlow with Apache License 2.0 | 5 votes |
def __init__(self, graph, value, name, dataType, accessLevel=AccessLevel.public, structure=StructureType.Single, uid=None): """Constructor :param graph: Owning graph :type graph: :class:`~PyFlow.Core.GraphBase.GraphBase` :param value: Variable value :type value: object :param name: Variable name :type name: str :param dataType: Variable data type :type dataType: str :param accessLevel: Variable access level :type accessLevel: :class:`~PyFlow.Core.Common.AccessLevel` :param structure: Variable structure :type structure: :attr:`~PyFlow.Core.Common.StructureType.Single` :param uid: Variable unique identifier :type uid: :class:`~uuid.UUID` """ super(Variable, self).__init__() self.nameChanged = Signal(str) self.valueChanged = Signal(str) self.dataTypeChanged = Signal(str) self.structureChanged = Signal(str) self.accessLevelChanged = Signal(str) self.killed = Signal() self.graph = graph self._name = name self._value = value self._dataType = dataType self._structure = structure self._accessLevel = accessLevel self._packageName = None self._uid = uuid.uuid4() if uid is None else uid assert(isinstance(self._uid, uuid.UUID)) self.updatePackageName() self._uiWrapper = None
Example #18
Source File: NodeBase.py From PyFlow with Apache License 2.0 | 5 votes |
def __init__(self, name, uid=None): super(NodeBase, self).__init__() self.bCacheEnabled = True self.cacheMaxSize = 1000 self.cache = {} self.killed = Signal() self.tick = Signal(float) self.setDirty = Signal() self.computing = Signal() self.computed = Signal() self.errorOccured = Signal(object) self.errorCleared = Signal() self.dirty = True self._uid = uuid.uuid4() if uid is None else uid self.graph = None self.name = name self.pinsCreationOrder = OrderedDict() self._pins = set() self.x = 0.0 self.y = 0.0 self.bCallable = False self._wrapper = None self._constraints = {} self._structConstraints = {} self.lib = None self.isCompoundNode = False self._lastError = None self.__wrapperJsonData = None self._nodeMetaData = None self.headerColor = None self._deprecated = False self._deprecationMessage = "This node is deprecated" self._experimental = False self._computingTime = None
Example #19
Source File: EditorHistory.py From PyFlow with Apache License 2.0 | 5 votes |
def __init__(self, app): self.statePushed = Signal(object) self.stateRemoved = Signal(object) self.stateSelected = Signal(object) self.app = app self.stack = list() try: self._capacity = int(ConfigManager().getPrefsValue("PREFS", "General/HistoryDepth")) except: self._capacity = 10 self.activeState = None
Example #20
Source File: message.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_requeue(self): """Emitted after :meth:`requeue`. The signal sender is the message instance and sends the ``timeout`` and a ``backoff`` flag as arguments. """ return blinker.Signal(doc='Emitted after message is requeued.')
Example #21
Source File: nsqd.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_response(self): """Emitted when a response frame is received. The signal sender is the connection and the ``response`` is sent as an argument. """ return blinker.Signal(doc='Emitted when a response frame is received.')
Example #22
Source File: nsqd.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_error(self): """Emitted when an error frame is received. The signal sender is the connection and the ``error`` is sent as an argument. """ return blinker.Signal(doc='Emitted when a error frame is received.')
Example #23
Source File: nsqd.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_finish(self): """Emitted after :meth:`finish`. Sent after a message owned by this connection is successfully finished. The signal sender is the connection and the ``message_id`` is sent as an argument. """ return blinker.Signal(doc='Emitted after the a message is finished.')
Example #24
Source File: nsqd.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_requeue(self): """Emitted after :meth:`requeue`. Sent after a message owned by this connection is requeued. The signal sender is the connection and the ``message_id``, ``timeout`` and ``backoff`` flag are sent as arguments. """ return blinker.Signal(doc='Emitted after the a message is requeued.')
Example #25
Source File: nsqd.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_close(self): """Emitted after :meth:`close_stream`. Sent after the connection socket has closed. The signal sender is the connection. """ return blinker.Signal(doc='Emitted after the connection is closed.')
Example #26
Source File: producer.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_response(self): """Emitted when a response is received. The signal sender is the consumer and the ` ` is sent as an argument. """ return blinker.Signal(doc='Emitted when a response is received.')
Example #27
Source File: producer.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_error(self): """Emitted when an error is received. The signal sender is the consumer and the ``error`` is sent as an argument. """ return blinker.Signal(doc='Emitted when a error is received.')
Example #28
Source File: producer.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_auth(self): """Emitted after a connection is successfully authenticated. The signal sender is the consumer and the ``conn`` and parsed ``response`` are sent as arguments. """ return blinker.Signal(doc='Emitted when a response is received.')
Example #29
Source File: producer.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_close(self): """Emitted after :meth:`close`. The signal sender is the consumer. """ return blinker.Signal(doc='Emitted after the consumer is closed.')
Example #30
Source File: consumer.py From gnsq with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_exception(self): """Emitted when an exception is caught while handling a message. The signal sender is the consumer and the ``message`` and ``error`` are sent as arguments. """ return blinker.Signal(doc='Emitted when an exception is caught.')