Ejemplo n.º 1
0
    def test_blockedjoin(self):

        from databot.flow import BlockedJoin

        def check(r):
            self.assertEqual(len(r), 2)
            self.assertTrue(isinstance(r[0], B))
            self.assertTrue(isinstance(r[0], B))

        p = Pipe(Loop([A()]), BlockedJoin(self.a_to_b, self.a_to_b), check)

        BotFrame.run()
Ejemplo n.º 2
0
    def test_blockedjoin_exception2(self):

        from databot.flow import BlockedJoin

        from databot.config import config
        config.exception_policy = config.Exception_pipein

        def raise_exception(a):
            raise Exception()

        def check(r):
            self.assertEqual(len(r), 2)
            self.assertTrue(isinstance(r[0], Exception))
            self.assertTrue(isinstance(r[1], B))

        p = Pipe(Loop([A()]), BlockedJoin(raise_exception, self.a_to_b), check)

        BotFrame.run()
        config.exception_policy = config.Exception_default
Ejemplo n.º 3
0
def main():

    httpload=HttpLoader(timeout=2)
    Pipe(

        Timer(delay=10,max_time=5),
        BlockedJoin(
            Return("https://api.kraken.com/0/public/Ticker?pair=XBTUSD",httpload , parse_kraken),
            Return("https://bittrex.com/api/v1.1/public/getticker?market=USD-BTC", httpload, parse_bittrex),
            Return("https://www.bitstamp.net/api/ticker/", httpload, parse_bitstamp),
            Return("https://api.bitfinex.com/v1/ticker/btcusd", httpload, parse_bitfinex),
            Return("https://bitpay.com/api/rates", httpload, parse_bitpay),
            Return("http://api.coindesk.com/v1/bpi/currentprice.json", httpload, parse_coindesk),
        ),
        print,
    )

    BotFrame.render('ex_output/bitcoin_arbitrage')
    BotFrame.run()
Ejemplo n.º 4
0
def main():
    Pipe(range(10), BlockedJoin(double, triple), print)

    BotFrame.render('ex_output/blockedjoin')
    BotFrame.run()
Ejemplo n.º 5
0
def main():
    Pipe(Loop(range(10)), BlockedJoin(double, triple), print)

    BotFrame.render('abc')
    BotFrame.run()