How to use the dispatch.Signal function in dispatch

To help you get started, we’ve selected a few dispatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github olivierverdier / dispatch / tests / test_dispatcher.py View on Github external
def receiver_1_arg(val, **kwargs):
    return val

class Callable(object):
    def __call__(self, val, **kwargs):
        return val
    
    def a(self, val, **kwargs):
        return val

class Sender(object):
    signal = Signal(providing_args=["val"])
    def send(self):
        self.signal.send(sender=self, val="test")

a_signal = Signal(providing_args=["val"])

class DispatcherTests(unittest.TestCase):
    """Test suite for dispatcher (barely started)"""

    def _testIsClean(self, signal):
        """Assert that everything has been cleaned up automatically"""
        self.assertEqual(signal.receivers, [])

        # force cleanup just in case
        signal.receivers = []
    
    def testExact(self):
        a_signal.connect(receiver_1_arg, sender=self)
        expected = [(receiver_1_arg,"test")]
        result = a_signal.send(sender=self, val="test")
        self.assertEqual(result, expected)
github olivierverdier / dispatch / tests / test_dispatcher.py View on Github external
else:
    def garbage_collect():
        gc.collect()

def receiver_1_arg(val, **kwargs):
    return val

class Callable(object):
    def __call__(self, val, **kwargs):
        return val
    
    def a(self, val, **kwargs):
        return val

class Sender(object):
    signal = Signal(providing_args=["val"])
    def send(self):
        self.signal.send(sender=self, val="test")

a_signal = Signal(providing_args=["val"])

class DispatcherTests(unittest.TestCase):
    """Test suite for dispatcher (barely started)"""

    def _testIsClean(self, signal):
        """Assert that everything has been cleaned up automatically"""
        self.assertEqual(signal.receivers, [])

        # force cleanup just in case
        signal.receivers = []
    
    def testExact(self):
github coinbay / CoinbayDEX / etherex / pyethereum / pyethereum / signals.py View on Github external
.. note::
    *sender* is used by *receiver* to specify which source to accept signal
    from, usually it's some *class name*.
    if you want to carry a instance arg, don't use it, instead, you can add one
    more arg in the signal's `provoding_args`
'''

config_ready = Signal(providing_args=["config"])

p2p_address_ready = Signal(providing_args=["ip", "port"])

peer_connection_accepted = Signal(providing_args=["connection", "ip", "port"])
peer_disconnect_requested = Signal(providing_args=["peer", "forget"])

peer_addresses_received = Signal(providing_args=["addresses"])
peer_handshake_success = Signal(providing_args=["peer"])

getpeers_received = Signal(providing_args=["peer"])
gettransactions_received = Signal(providing_args=["peer"])

remote_blocks_received = Signal(providing_args=["block_lst", "peer"])
remote_chain_requested = Signal(providing_args=["parents", "count"])
local_chain_requested = Signal(providing_args=["peer", "blocks", "count"])
send_local_blocks = Signal(providing_args=["blocks"])

local_transaction_received = Signal(providing_args=["transaction"])
remote_transactions_received = Signal(providing_args=["transactions"])
send_local_transactions = Signal(providing_args=["transaction"])
github coinbay / CoinbayDEX / etherex / pyethereum / pyethereum / signals.py View on Github external
if you want to carry a instance arg, don't use it, instead, you can add one
    more arg in the signal's `provoding_args`
'''

config_ready = Signal(providing_args=["config"])

p2p_address_ready = Signal(providing_args=["ip", "port"])

peer_connection_accepted = Signal(providing_args=["connection", "ip", "port"])
peer_disconnect_requested = Signal(providing_args=["peer", "forget"])

peer_addresses_received = Signal(providing_args=["addresses"])
peer_handshake_success = Signal(providing_args=["peer"])

getpeers_received = Signal(providing_args=["peer"])
gettransactions_received = Signal(providing_args=["peer"])

remote_blocks_received = Signal(providing_args=["block_lst", "peer"])
remote_chain_requested = Signal(providing_args=["parents", "count"])
local_chain_requested = Signal(providing_args=["peer", "blocks", "count"])
send_local_blocks = Signal(providing_args=["blocks"])

local_transaction_received = Signal(providing_args=["transaction"])
remote_transactions_received = Signal(providing_args=["transactions"])
send_local_transactions = Signal(providing_args=["transaction"])
github geeknam / esser / esser / signals / __init__.py View on Github external
import dispatch

event_received = dispatch.Signal(
    providing_args=['aggregate_name', 'aggregate_id', 'payload']
)

event_pre_save = dispatch.Signal(
    providing_args=[
        'aggregate_name', 'aggregate_id', 'payload',
        'event_name', 'version',
    ]
)

event_post_save = dispatch.Signal(
    providing_args=['event']
)
github biothings / mygene.info / src / tools / dispatcher.py View on Github external
import time
from subprocess import Popen
from datetime import datetime
import dispatch

from biothings.utils.common import timesofar
from utils.common import src_path
from biothings.utils.mongo import src_clean_archives, target_clean_collections
from dataload.dispatch import (check_mongo, get_process_info, src_dump,
                               mark_upload_started, mark_upload_done)
from dataload.dispatch import dispatch as dispatch_src_upload

from config import DATA_WWW_ROOT_URL

source_update_available = dispatch.Signal(providing_args=["src_to_update"])
source_upload_success = dispatch.Signal(providing_args=["src_name"])
source_upload_failed = dispatch.Signal(providing_args=["src_name"])
genedoc_merged = dispatch.Signal()
es_indexed = dispatch.Signal()

try:
    from utils.common import hipchat_msg
except:
    hipchat_msg = None


class GeneDocDispatcher:
    running_processes_upload = {}
    idle = True

    def check_src_dump(self):
        src_to_update_li = check_mongo()
github gbozee / pypaystack / paystack / signals.py View on Github external
from dispatch import Signal

payment_verified = Signal(providing_args=["ref", "amount", "order"])

event_signal = Signal(providing_args=['event', "data"])

successful_payment_signal = Signal(providing_args=['data'])

successful_transfer_signal = Signal(providing_args=['transfer_code', 'data'])

failed_transfer_signal = Signal(providing_args=['transfer_code', 'data'])
github biothings / mygene.info / src / tools / dispatcher.py View on Github external
from datetime import datetime
import dispatch

from biothings.utils.common import timesofar
from utils.common import src_path
from biothings.utils.mongo import src_clean_archives, target_clean_collections
from dataload.dispatch import (check_mongo, get_process_info, src_dump,
                               mark_upload_started, mark_upload_done)
from dataload.dispatch import dispatch as dispatch_src_upload

from config import DATA_WWW_ROOT_URL

source_update_available = dispatch.Signal(providing_args=["src_to_update"])
source_upload_success = dispatch.Signal(providing_args=["src_name"])
source_upload_failed = dispatch.Signal(providing_args=["src_name"])
genedoc_merged = dispatch.Signal()
es_indexed = dispatch.Signal()

try:
    from utils.common import hipchat_msg
except:
    hipchat_msg = None


class GeneDocDispatcher:
    running_processes_upload = {}
    idle = True

    def check_src_dump(self):
        src_to_update_li = check_mongo()
        if src_to_update_li:
            print('\nDispatcher:  found pending jobs ', src_to_update_li)
github coinbay / CoinbayDEX / etherex / pyethereum / pyethereum / signals.py View on Github external
from, usually it's some *class name*.
    if you want to carry a instance arg, don't use it, instead, you can add one
    more arg in the signal's `provoding_args`
'''

config_ready = Signal(providing_args=["config"])

p2p_address_ready = Signal(providing_args=["ip", "port"])

peer_connection_accepted = Signal(providing_args=["connection", "ip", "port"])
peer_disconnect_requested = Signal(providing_args=["peer", "forget"])

peer_addresses_received = Signal(providing_args=["addresses"])
peer_handshake_success = Signal(providing_args=["peer"])

getpeers_received = Signal(providing_args=["peer"])
gettransactions_received = Signal(providing_args=["peer"])

remote_blocks_received = Signal(providing_args=["block_lst", "peer"])
remote_chain_requested = Signal(providing_args=["parents", "count"])
local_chain_requested = Signal(providing_args=["peer", "blocks", "count"])
send_local_blocks = Signal(providing_args=["blocks"])

local_transaction_received = Signal(providing_args=["transaction"])
remote_transactions_received = Signal(providing_args=["transactions"])
send_local_transactions = Signal(providing_args=["transaction"])
github coinbay / CoinbayDEX / etherex / pyethereum / pyethereum / signals.py View on Github external
'''
.. note::
    *sender* is used by *receiver* to specify which source to accept signal
    from, usually it's some *class name*.
    if you want to carry a instance arg, don't use it, instead, you can add one
    more arg in the signal's `provoding_args`
'''

config_ready = Signal(providing_args=["config"])

p2p_address_ready = Signal(providing_args=["ip", "port"])

peer_connection_accepted = Signal(providing_args=["connection", "ip", "port"])
peer_disconnect_requested = Signal(providing_args=["peer", "forget"])

peer_addresses_received = Signal(providing_args=["addresses"])
peer_handshake_success = Signal(providing_args=["peer"])

getpeers_received = Signal(providing_args=["peer"])
gettransactions_received = Signal(providing_args=["peer"])

remote_blocks_received = Signal(providing_args=["block_lst", "peer"])
remote_chain_requested = Signal(providing_args=["parents", "count"])
local_chain_requested = Signal(providing_args=["peer", "blocks", "count"])
send_local_blocks = Signal(providing_args=["blocks"])

local_transaction_received = Signal(providing_args=["transaction"])
remote_transactions_received = Signal(providing_args=["transactions"])
send_local_transactions = Signal(providing_args=["transaction"])