44for execution, supporting both in-memory and persistent storage scenarios.
55"""
66
7+ from abc import abstractmethod
78from collections .abc import Sequence
89from typing import Protocol
910
@@ -35,6 +36,7 @@ class ReadyQueue(Protocol):
3536 that can be serialized for state storage.
3637 """
3738
39+ @abstractmethod
3840 def put (self , item : str ) -> None :
3941 """Add a node ID to the ready queue.
4042
@@ -44,6 +46,7 @@ def put(self, item: str) -> None:
4446 """
4547 ...
4648
49+ @abstractmethod
4750 def get (self , timeout : float | None = None ) -> str :
4851 """Retrieve and remove a node ID from the queue.
4952
@@ -56,6 +59,7 @@ def get(self, timeout: float | None = None) -> str:
5659 """
5760 ...
5861
62+ @abstractmethod
5963 def task_done (self ) -> None :
6064 """Indicate that a previously retrieved task is complete.
6165
@@ -64,6 +68,7 @@ def task_done(self) -> None:
6468 """
6569 ...
6670
71+ @abstractmethod
6772 def empty (self ) -> bool :
6873 """Check if the queue is empty.
6974
@@ -73,6 +78,7 @@ def empty(self) -> bool:
7378 """
7479 ...
7580
81+ @abstractmethod
7682 def qsize (self ) -> int :
7783 """Get the approximate size of the queue.
7884
@@ -82,6 +88,7 @@ def qsize(self) -> int:
8288 """
8389 ...
8490
91+ @abstractmethod
8592 def dumps (self ) -> str :
8693 """Serialize the queue state to a JSON string for storage.
8794
@@ -92,6 +99,7 @@ def dumps(self) -> str:
9299 """
93100 ...
94101
102+ @abstractmethod
95103 def loads (self , data : str ) -> None :
96104 """Restore the queue state from a JSON string.
97105
0 commit comments