fix: python async (#309)

* fix: python async

* fix python async
This commit is contained in:
stefan-gorules
2025-02-08 17:28:58 +01:00
committed by GitHub
parent 9ca7ee0cc2
commit 55a6320580
10 changed files with 219 additions and 68 deletions
+14 -1
View File
@@ -2,6 +2,7 @@ import asyncio
import glob
import json
import os.path
import time
import unittest
import zen
@@ -26,7 +27,7 @@ def custom_handler(request):
async def custom_async_handler(request):
p1 = request.get_field("prop1")
await asyncio.sleep(0.25)
await asyncio.sleep(0.1)
return {
"output": {"sum": p1}
}
@@ -55,6 +56,18 @@ class AsyncZenEngine(unittest.IsolatedAsyncioTestCase):
self.assertEqual(results[1]["result"]["sum"], 30)
self.assertEqual(results[2]["result"]["sum"], 40)
async def test_async_sleep_function(self):
engine = zen.ZenEngine({"loader": loader, "customHandler": custom_async_handler})
await engine.async_evaluate("sleep-function.json", {})
self.assertTrue(True)
async def test_async_http_function(self):
engine = zen.ZenEngine({"loader": loader, "customHandler": custom_async_handler})
await engine.async_evaluate("http-function.json", {})
self.assertTrue(True)
async def test_create_decisions_from_content(self):
engine = zen.ZenEngine()
with open("../../test-data/function.json", "r") as f: