Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def handler(self):
message = "hello world\n"
timeout = await appier.sleep(3.0)
message += "timeout: %.2f\n" % timeout
result = await self.calculator(2, 2)
message += "result: %d\n" % result
await appier.await_yield("hello world\n")
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)
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