Skip to content

Commit 3ea5881

Browse files
acul71seetadev
andauthored
Fix issue libp2p#1071: Add task_status support to host.run() method (libp2p#1074)
- Update BasicHost.run() to accept task_status keyword argument - Update IHost.run() abstract method signature to match - Add newsfragment for the bugfix - Fixes compatibility with modern pytest-trio (>=0.8.0) and trio (>=0.26.0) Co-authored-by: Manu Sheel Gupta <[email protected]>
1 parent a720fed commit 3ea5881

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

libp2p/abc.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1845,7 +1845,10 @@ def get_live_peers(self) -> list[ID]:
18451845

18461846
@abstractmethod
18471847
def run(
1848-
self, listen_addrs: Sequence[Multiaddr]
1848+
self,
1849+
listen_addrs: Sequence[Multiaddr],
1850+
*,
1851+
task_status: Any = trio.TASK_STATUS_IGNORED,
18491852
) -> AbstractAsyncContextManager[None]:
18501853
"""
18511854
Run the host and start listening on the specified multiaddresses.
@@ -1854,6 +1857,8 @@ def run(
18541857
----------
18551858
listen_addrs : Sequence[Multiaddr]
18561859
A sequence of multiaddresses on which the host should listen.
1860+
task_status : Any
1861+
Task status for trio nursery compatibility (ignored).
18571862
18581863
"""
18591864

libp2p/host/basic_host.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import logging
1212
from typing import (
1313
TYPE_CHECKING,
14+
Any,
1415
)
1516
import weakref
1617

@@ -331,12 +332,16 @@ def get_connected_peers(self) -> list[ID]:
331332
return list(self._network.connections.keys())
332333

333334
def run(
334-
self, listen_addrs: Sequence[multiaddr.Multiaddr]
335+
self,
336+
listen_addrs: Sequence[multiaddr.Multiaddr],
337+
*,
338+
task_status: Any = trio.TASK_STATUS_IGNORED,
335339
) -> AbstractAsyncContextManager[None]:
336340
"""
337341
Run the host instance and listen to ``listen_addrs``.
338342
339343
:param listen_addrs: a sequence of multiaddrs that we want to listen to
344+
:param task_status: task status for trio nursery compatibility (ignored)
340345
"""
341346

342347
@asynccontextmanager

newsfragments/1071.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed BasicHost.run() to accept task_status keyword argument for compatibility with modern pytest-trio (>=0.8.0) and trio (>=0.26.0).

0 commit comments

Comments
 (0)