Skip to content

Commit

Permalink
feat(framework) Introduce pull_interval in InMemoryDriver (#4290)
Browse files Browse the repository at this point in the history
  • Loading branch information
jafermarq authored Oct 8, 2024
1 parent 850ccce commit 270f823
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/py/flwr/server/driver/inmemory_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,20 @@ class InMemoryDriver(Driver):
The identifier of the run.
state_factory : StateFactory
A StateFactory embedding a state that this driver can interface with.
pull_interval : float (default=0.1)
Sleep duration between calls to `pull_messages`.
"""

def __init__(
self,
run_id: int,
state_factory: StateFactory,
pull_interval: float = 0.1,
) -> None:
self._run_id = run_id
self._run: Optional[Run] = None
self.state = state_factory.state()
self.pull_interval = pull_interval
self.node = Node(node_id=0, anonymous=True)

def _check_message(self, message: Message) -> None:
Expand Down Expand Up @@ -180,5 +184,5 @@ def send_and_receive(
if len(msg_ids) == 0:
break
# Sleep
time.sleep(3)
time.sleep(self.pull_interval)
return ret

0 comments on commit 270f823

Please sign in to comment.