Skip to content

Commit

Permalink
feat: added timeout option to network interface
Browse files Browse the repository at this point in the history
  • Loading branch information
naman108 committed Nov 27, 2024
1 parent ed14edd commit df6356f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions digitalpy/core/network/network_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@


class NetworkInterface(ABC):
"""Network Interface class. Defines the interface for all networking implementations
"""
"""Network Interface class. Defines the interface for all networking implementations"""

@abstractmethod
def service_connections(self) -> List[Request]:
def service_connections(
self, max_requests: int = 1000, blocking: bool = False, timeout: int = 0
) -> List[Request]:
"""service all connections to the server and return a list of Requests
Args:
max_requests (int, optional): the maximum number of requests to service. Defaults to 1000.
blocking (bool, optional): whether or not to block until a request is received. Defaults to False.
timeout (int, optional): the number of seconds to wait for a request before returning. Defaults to 0.
Returns:
List[Request]: _description_
List[Request]: a list of requests that were received
"""

@abstractmethod
def initialize_network(self, host: str, port: int, *args, **kwargs):
"""initialize the network connection, bind to the port and host.
"""
"""initialize the network connection, bind to the port and host."""

@abstractmethod
def teardown_network(self):
"""stop listening for messages from the network and release all files and resources
"""
"""stop listening for messages from the network and release all files and resources"""

@abstractmethod
def receive_message(self, blocking: bool = False) -> Request:
Expand Down

0 comments on commit df6356f

Please sign in to comment.