@@ -78,31 +78,6 @@ async def _run(self) -> None:
7878 print (f"{ self } done (should not happen)" )
7979
8080
81- class RaiseBaseExceptionActor (BaseTestActor ):
82- """A faulty actor that raises a BaseException as soon as it receives a message."""
83-
84- def __init__ (
85- self ,
86- recv : Receiver [int ],
87- ) -> None :
88- """Create an instance.
89-
90- Args:
91- recv: A channel receiver for int data.
92- """
93- super ().__init__ (name = "test" )
94- self ._recv = recv
95-
96- async def _run (self ) -> None :
97- """Start the actor and crash upon receiving a message."""
98- print (f"{ self } started" )
99- self .inc_restart_count ()
100- async for _ in self ._recv :
101- print (f"{ self } is about to crash" )
102- raise MyBaseException ("This is a test" )
103- print (f"{ self } done (should not happen)" )
104-
105-
10681ACTOR_INFO = ("frequenz.sdk.actor._actor" , 20 )
10782ACTOR_ERROR = ("frequenz.sdk.actor._actor" , 40 )
10883RUN_INFO = ("frequenz.sdk.actor._run_utils" , 20 )
@@ -309,41 +284,6 @@ async def test_does_not_restart_on_normal_exit(
309284 ]
310285
311286
312- async def test_does_not_restart_on_base_exception (
313- actor_auto_restart_once : None , # pylint: disable=unused-argument
314- caplog : pytest .LogCaptureFixture ,
315- ) -> None :
316- """Create a faulty actor and expect it not to restart because it raises a base exception."""
317- caplog .set_level ("DEBUG" , logger = "frequenz.sdk.actor._actor" )
318- caplog .set_level ("DEBUG" , logger = "frequenz.sdk.actor._run_utils" )
319-
320- channel : Broadcast [int ] = Broadcast (name = "channel" )
321-
322- actor = RaiseBaseExceptionActor (channel .new_receiver ())
323-
324- async with asyncio .timeout (1.0 ):
325- await channel .new_sender ().send (1 )
326- # We can't use pytest.raises() here because known BaseExceptions are handled
327- # specially by pytest.
328- try :
329- await run (actor )
330- except MyBaseException as error :
331- assert str (error ) == "This is a test"
332-
333- assert BaseTestActor .restart_count == 0
334- assert caplog .record_tuples == [
335- (* RUN_INFO , "Starting 1 actor(s)..." ),
336- (* RUN_INFO , "Actor RaiseBaseExceptionActor[test]: Starting..." ),
337- (* ACTOR_INFO , "Actor RaiseBaseExceptionActor[test]: Started." ),
338- (* ACTOR_ERROR , "Actor RaiseBaseExceptionActor[test]: Raised a BaseException." ),
339- (
340- * RUN_ERROR ,
341- "Actor RaiseBaseExceptionActor[test]: Raised an exception while running." ,
342- ),
343- (* RUN_INFO , "All 1 actor(s) finished." ),
344- ]
345-
346-
347287async def test_does_not_restart_if_cancelled (
348288 actor_auto_restart_once : None , # pylint: disable=unused-argument
349289 caplog : pytest .LogCaptureFixture ,
@@ -390,6 +330,6 @@ async def cancel_actor() -> None:
390330 (* RUN_INFO , "Actor EchoActor[EchoActor]: Starting..." ),
391331 (* ACTOR_INFO , "Actor EchoActor[EchoActor]: Started." ),
392332 (* ACTOR_INFO , "Actor EchoActor[EchoActor]: Cancelled." ),
393- (* RUN_ERROR , "Actor EchoActor[EchoActor]: Raised an exception while running." ),
333+ (* RUN_INFO , "Actor EchoActor[EchoActor]: Cancelled while running." ),
394334 (* RUN_INFO , "All 1 actor(s) finished." ),
395335 ]
0 commit comments