How to use the appier.sleep function in appier

To help you get started, we’ve selected a few appier 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 hivesolutions / appier / examples / async / async.py View on Github external
def calculator(self, *args, **kwargs):
        print("computing...")
        yield from appier.sleep(3.0)
        print("finished computing...")
        return sum(args)
github hivesolutions / appier / examples / async / async_old.py View on Github external
def handler_partial(self):
        yield "hello world\n"
        for value in appier.sleep(3.0): yield value
        yield "timeout: %.2f\n" % 3.0
        result = appier.build_future()
        for value in self.calculator(result, 2, 2): yield value
        yield "result: %d\n" % result.result()
github hivesolutions / appier / examples / async / async_neo.py View on Github external
async def handler_partial(self):
        await appier.await_yield("hello world\n")
        timeout = await appier.sleep(3.0)
        await appier.await_yield("timeout: %.2f\n" % timeout)
        result = await self.calculator(2, 2)
        await appier.await_yield("result: %d\n" % result)
github hivesolutions / appier / examples / async / async_old.py View on Github external
def calculator(self, future, *args, **kwargs):
        print("computing...")
        for value in appier.sleep(3.0): yield value
        print("finished computing...")
        future.set_result(sum(args))
github hivesolutions / appier / examples / async / async.py View on Github external
def handler_partial(self):
        yield "hello world\n"
        timeout = yield from appier.sleep(3.0)
        yield "timeout: %.2f\n" % timeout
        result = yield from self.calculator(2, 2)
        yield "result: %d\n" % result
github hivesolutions / appier / examples / async / async.py View on Github external
def read_file(self, file_path, chunk = 65536, delay = 0.0):
        count = 0
        file = open(file_path, "rb")
        try:
            while True:
                data = file.read(chunk)
                if not data: break
                count += len(data)
                if delay: yield from appier.sleep(delay)
                yield data
        finally:
            file.close()
        return count
github hivesolutions / appier / examples / async / async_neo.py View on Github external
async def http(self):
        url = self.field("url", "https://www.flickr.com/")
        delay = self.field("delay", 0.0, cast = float)
        self.request.content_type = "text/html"
        await appier.sleep(delay)
        yield await appier.get_w(url)
github hivesolutions / appier / examples / async / async_neo.py View on Github external
async def read_file(self, file_path, chunk = 65536, delay = 0.0):
        count = 0
        file = open(file_path, "rb")
        try:
            while True:
                data = file.read(chunk)
                if not data: break
                count += len(data)
                if delay: await appier.sleep(delay)
                await appier.await_yield(data)
        finally:
            file.close()
        return count
github hivesolutions / appier / examples / async / async.py View on Github external
def handler(self):
        message = "hello world\n"
        timeout = yield from appier.sleep(3.0)
        message += "timeout: %.2f\n" % timeout
        result = yield from self.calculator(2, 2)
        message += "result: %d\n" % result
        yield message