feat: Add performance monitoring and type safety improvements

- Add performance monitoring for serialization
- Add type safety protocols
- Add concurrent access test
- Improve error handling
- Optimize thread-safe primitive detection

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-02-14 06:27:04 +00:00
parent 5467a70d97
commit b98e720531
2 changed files with 144 additions and 75 deletions

View File

@@ -157,3 +157,26 @@ def test_flow_with_async_locks():
result = asyncio.run(flow.kickoff_async())
assert result == "step 1 -> step 2"
assert flow.state.value == "step 1 -> step 2"
def test_flow_concurrent_access():
"""Test Flow with concurrent access."""
flow = LockFlow()
results = []
errors = []
async def run_flow():
try:
result = await flow.kickoff_async()
results.append(result)
except Exception as e:
errors.append(e)
async def test():
tasks = [run_flow() for _ in range(10)]
await asyncio.gather(*tasks)
asyncio.run(test())
assert len(results) == 10
assert not errors
assert all(result == "step 1 -> step 2" for result in results)