Exemplo n.º 1
0
 def calculator(self, *args, **kwargs):
     thread = threading.current_thread()
     print("executing in %s" % thread)
     print("computing...")
     yield from appier.sleep(3.0)
     print("finished computing...")
     return sum(args)
Exemplo n.º 2
0
 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()
Exemplo n.º 3
0
 def calculator(self, *args, **kwargs):
     thread = threading.current_thread()
     print("executing in %s" % thread)
     print("computing...")
     yield from appier.sleep(3.0)
     print("finished computing...")
     return sum(args)
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 def handler_partial(self, future):
     yield "hello world\n"
     for value in appier.sleep(3.0): yield value
     yield "timeout: %.2f\n" % 3.0
     result = appier.Future()
     for value in self.calculator(result, 2, 2): yield value
     yield "result: %d\n" % result.result()
Exemplo n.º 6
0
 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"
     for value in appier.header_a(): yield value
     for value in appier.sleep(delay): yield value
     for value in appier.get_a(url): yield value
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
 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"
     yield from appier.header_a()
     yield from appier.sleep(delay)
     yield (yield from appier.get_a(url))
Exemplo n.º 9
0
 def handler(self):
     message = "hello world\n"
     for value in appier.sleep(3.0): yield value
     message += "timeout: %.2f\n" % 3.0
     future = appier.build_future()
     for value in self.calculator(future, 2, 2): yield value
     message += "result: %d\n" % future.result()
     yield message
Exemplo n.º 10
0
 def handler(self, future):
     message = "hello world\n"
     for value in appier.sleep(3.0): yield value
     message += "timeout: %.2f\n" % 3.0
     result = appier.Future()
     for value in self.calculator(result, 2, 2): yield value
     message += "result: %d\n" % result.result()
     future.set_result(message)
Exemplo n.º 11
0
 def handler(self):
     message = "hello world\n"
     for value in appier.sleep(3.0): yield value
     message += "timeout: %.2f\n" % 3.0
     future = appier.build_future()
     for value in self.calculator(future, 2, 2): yield value
     message += "result: %d\n" % future.result()
     yield message
Exemplo n.º 12
0
 def handler(self, future):
     thread = threading.current_thread()
     print("executing in %s" % thread)
     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
     future.set_result(message)
Exemplo n.º 13
0
 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"
     for value in appier.header_a(): yield value
     for value in appier.sleep(delay): yield value
     for value in appier.get_a(url):
         yield value
         yield value.result()
Exemplo n.º 14
0
 def handler(self, future):
     message = "hello world\n"
     for value in appier.sleep(3.0):
         yield value
     message += "timeout: %.2f\n" % 3.0
     for value in self.calculator(2, 2):
         yield value
     message += "result: %d\n" % 4
     future.set_result(message)
Exemplo n.º 15
0
 def handler(self, future):
     thread = threading.current_thread()
     print("executing in %s" % thread)
     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
     future.set_result(message)
Exemplo n.º 16
0
 def read_file(self, future, 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:
                 for value in appier.sleep(delay): yield value
             yield data
     finally:
         file.close()
Exemplo n.º 17
0
 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
Exemplo n.º 18
0
 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))
Exemplo n.º 19
0
 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))
Exemplo n.º 20
0
 def handler_partial(self, future):
     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
Exemplo n.º 21
0
 def calculator(self, *args, **kwargs):
     print("computing...")
     yield from appier.sleep(3.0)
     print("finished computing...")
     return sum(args)
Exemplo n.º 22
0
 def calculator(self, *args, **kwargs):
     print("computing...")
     for value in appier.sleep(3.0):
         yield value
     print("finished computing...")
Exemplo n.º 23
0
 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
Exemplo n.º 24
0
 def calculator(self, *args, **kwargs):
     print("computing...")
     yield from appier.sleep(3.0)
     print("finished computing...")
     return sum(args)