22import threading
33import time
44
5- from durabletask . worker import ConcurrencyOptions , TaskHubGrpcWorker
5+ from durabletask import worker
66
77
88class DummyStub :
@@ -37,12 +37,12 @@ class DummyCompletionToken:
3737 pass
3838
3939def test_worker_concurrency_loop_sync ():
40- options = ConcurrencyOptions (
40+ options = worker . ConcurrencyOptions (
4141 maximum_concurrent_activity_work_items = 2 ,
4242 maximum_concurrent_orchestration_work_items = 1 ,
4343 maximum_thread_pool_workers = 2 ,
4444 )
45- worker = TaskHubGrpcWorker (concurrency_options = options )
45+ grpc_worker = worker . TaskHubGrpcWorker (concurrency_options = options )
4646 stub = DummyStub ()
4747
4848 def dummy_orchestrator (req , stub , completionToken ):
@@ -54,25 +54,25 @@ def dummy_activity(req, stub, completionToken):
5454 stub .CompleteActivityTask ('ok' )
5555
5656 # Patch the worker's _execute_orchestrator and _execute_activity
57- worker ._execute_orchestrator = dummy_orchestrator
58- worker ._execute_activity = dummy_activity
57+ grpc_worker ._execute_orchestrator = dummy_orchestrator
58+ grpc_worker ._execute_activity = dummy_activity
5959
6060 orchestrator_requests = [DummyRequest ('orchestrator' , f'orch{ i } ' ) for i in range (3 )]
6161 activity_requests = [DummyRequest ('activity' , f'act{ i } ' ) for i in range (4 )]
6262
6363 async def run_test ():
6464 # Start the worker manager's run loop in the background
65- worker_task = asyncio .create_task (worker ._async_worker_manager .run ())
65+ worker_task = asyncio .create_task (grpc_worker ._async_worker_manager .run ())
6666 for req in orchestrator_requests :
67- worker ._async_worker_manager .submit_orchestration (dummy_orchestrator , req , stub , DummyCompletionToken ())
67+ grpc_worker ._async_worker_manager .submit_orchestration (dummy_orchestrator , req , stub , DummyCompletionToken ())
6868 for req in activity_requests :
69- worker ._async_worker_manager .submit_activity (dummy_activity , req , stub , DummyCompletionToken ())
69+ grpc_worker ._async_worker_manager .submit_activity (dummy_activity , req , stub , DummyCompletionToken ())
7070 await asyncio .sleep (1.0 )
7171 orchestrator_count = sum (1 for t , _ in stub .completed if t == 'orchestrator' )
7272 activity_count = sum (1 for t , _ in stub .completed if t == 'activity' )
7373 assert orchestrator_count == 3 , f"Expected 3 orchestrator completions, got { orchestrator_count } "
7474 assert activity_count == 4 , f"Expected 4 activity completions, got { activity_count } "
75- worker ._async_worker_manager ._shutdown = True
75+ grpc_worker ._async_worker_manager ._shutdown = True
7676 await worker_task
7777 asyncio .run (run_test ())
7878
0 commit comments