@@ -1189,46 +1189,3 @@ def shutdown(self) -> None:
11891189 if self .next_exception_task :
11901190 self .next_exception_task .cancel ()
11911191 setattr (self .worker ._bridge_worker , self .attr , self .orig_poll_call )
1192-
1193-
1194- class MyCombinedPlugin (temporalio .client .Plugin , temporalio .worker .Plugin ):
1195- def configure_worker (self , config : WorkerConfig ) -> WorkerConfig :
1196- print ("Create worker combined plugin" )
1197- config ["task_queue" ] = "combined"
1198- return super ().configure_worker (config )
1199-
1200-
1201- class MyWorkerPlugin (temporalio .worker .Plugin ):
1202- def configure_worker (self , config : WorkerConfig ) -> WorkerConfig :
1203- print ("Create worker worker plugin" )
1204- config ["task_queue" ] = "replaced_queue"
1205- return super ().configure_worker (config )
1206-
1207- async def run_worker (self , worker : Worker ) -> None :
1208- await super ().run_worker (worker )
1209-
1210-
1211- async def test_worker_plugin (client : Client ) -> None :
1212- worker = Worker (
1213- client ,
1214- task_queue = "queue" ,
1215- activities = [never_run_activity ],
1216- plugins = [MyWorkerPlugin ()],
1217- )
1218- assert worker .config ().get ("task_queue" ) == "replaced_queue"
1219-
1220- # Test client plugin propagation to worker plugins
1221- new_config = client .config ()
1222- new_config ["plugins" ] = [MyCombinedPlugin ()]
1223- client = Client (** new_config )
1224- worker = Worker (client , task_queue = "queue" , activities = [never_run_activity ])
1225- assert worker .config ().get ("task_queue" ) == "combined"
1226-
1227- # Test both. Client propagated plugins are called first, so the worker plugin overrides in this case
1228- worker = Worker (
1229- client ,
1230- task_queue = "queue" ,
1231- activities = [never_run_activity ],
1232- plugins = [MyWorkerPlugin ()],
1233- )
1234- assert worker .config ().get ("task_queue" ) == "replaced_queue"
0 commit comments