Skip to content

Commit

Permalink
Mark internal Actor methods as abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
jodal committed Jul 17, 2024
1 parent 28aa286 commit 1f4a1f6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/pykka/_actor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import abc
import logging
import sys
import threading
Expand Down Expand Up @@ -32,7 +33,7 @@ def get(self) -> Envelope[Any]: ...
def empty(self) -> bool: ...


class Actor:
class Actor(abc.ABC):
"""An actor is an execution unit that executes concurrently with other actors.
To create an actor:
Expand Down Expand Up @@ -122,6 +123,7 @@ def start(
return obj.actor_ref

@staticmethod
@abc.abstractmethod
def _create_actor_inbox() -> ActorInbox:
"""Create an inbox for the actor.
Expand All @@ -131,6 +133,7 @@ def _create_actor_inbox() -> ActorInbox:
raise NotImplementedError(msg)

@staticmethod
@abc.abstractmethod
def _create_future() -> Future[Any]:
"""Create a future for the actor.
Expand All @@ -139,6 +142,7 @@ def _create_future() -> Future[Any]:
msg = "Use a subclass of Actor"
raise NotImplementedError(msg)

@abc.abstractmethod
def _start_actor_loop(self) -> None:
"""Create and start the actor's event loop.
Expand Down Expand Up @@ -275,7 +279,7 @@ def _actor_loop_teardown(self) -> None:
)
)

def on_start(self) -> None:
def on_start(self) -> None: # noqa: B027
"""Run code at the beginning of the actor's life.
Hook for doing any setup that should be done *after* the actor is
Expand All @@ -289,7 +293,7 @@ def on_start(self) -> None:
logged, and the actor will stop.
"""

def on_stop(self) -> None:
def on_stop(self) -> None: # noqa: B027
"""Run code at the end of the actor's life.
Hook for doing any cleanup that should be done *after* the actor has
Expand Down Expand Up @@ -319,7 +323,7 @@ def _handle_failure(
ActorRegistry.unregister(self.actor_ref)
self.actor_stopped.set()

def on_failure(
def on_failure( # noqa: B027
self,
exception_type: Optional[type[BaseException]],
exception_value: Optional[BaseException],
Expand Down

0 comments on commit 1f4a1f6

Please sign in to comment.