Skip to content

Commit 73714c6

Browse files
committed
switch from bpython to IPython to avoid greenlet exception
1 parent e24a465 commit 73714c6

File tree

6 files changed

+252
-264
lines changed

6 files changed

+252
-264
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ explicit = true
7777

7878
[dependency-groups]
7979
dev = [
80-
"bpython>=0.25",
80+
"ipython>=8.37.0",
8181
"mypy>=1.17.1",
8282
"pdoc>=15.0.4",
8383
"pre-commit>=4.3.0",

scripts/auto/anchor.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
11
"""anchor.py: creates and starts an anchor node for testing."""
2+
import sys
3+
4+
import IPython
5+
6+
from chordnet import Node as ChordNode
7+
8+
9+
def main() -> None:
10+
"""Creates a new ring with this computer as the only node."""
11+
if len(sys.argv) != 3:
12+
print("usage: [uv run] python anchor.py ip_addr port_no")
13+
exit(1)
14+
15+
ip = sys.argv[1]
16+
port = int(sys.argv[2])
17+
18+
node = ChordNode(ip, port, debug=True)
19+
# create (start) the ring
20+
node.create()
21+
print(f"Node created as \"node\": {node.address}", file=sys.stderr)
22+
repl_locals = {
23+
'node': node,
24+
}
25+
print("starting repl. access `node`")
26+
IPython.embed(user_ns=repl_locals)
27+
node.stop()
28+
29+
30+
if __name__ == '__main__':
31+
main()

scripts/auto/joiner.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
11
"""joiner.py: creates a joining node for debugging."""
2+
import sys
3+
4+
import IPython
5+
6+
from chordnet import Node as ChordNode
7+
8+
9+
def main() -> None:
10+
"""Creates a new ring with this computer as the only node."""
11+
if len(sys.argv) != 5:
12+
print("usage: [uv run] python " \
13+
"joiner.py this_ip this_port target_ip target_port")
14+
exit(1)
15+
16+
# Get IP and port from command line arguments
17+
ip = sys.argv[1]
18+
port = int(sys.argv[2])
19+
target_ip = sys.argv[3]
20+
target_port = int(sys.argv[4])
21+
22+
# Create and join node
23+
node = ChordNode(ip, port, debug=True)
24+
node.join(target_ip, target_port)
25+
repl_locals = {
26+
'node': node,
27+
}
28+
print("starting repl. access `node`, advance with `step(node)`")
29+
IPython.embed(user_ns=repl_locals)
30+
node.stop()
31+
32+
33+
if __name__ == '__main__':
34+
main()

scripts/manual/anchor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""anchor.py: creates and starts an anchor node for testing."""
22
import sys
33

4-
import bpython
4+
import IPython
55
from step import step #type: ignore
66

77
from chordnet import Node as ChordNode
@@ -25,7 +25,7 @@ def main() -> None:
2525
'step': step,
2626
}
2727
print("starting repl. access `node`, advance with `step(node)`")
28-
bpython.embed(locals_=repl_locals)
28+
IPython.embed(user_ns=repl_locals)
2929
node.stop()
3030

3131

scripts/manual/joiner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""joiner.py: creates a joining node for debugging."""
22
import sys
33

4-
import bpython
4+
import IPython
55
from step import step #type: ignore
66

77
from chordnet import Node as ChordNode
@@ -28,7 +28,7 @@ def main() -> None:
2828
'step': step,
2929
}
3030
print("starting repl. access `node`, advance with `step(node)`")
31-
bpython.embed(locals_=repl_locals)
31+
IPython.embed(user_ns=repl_locals)
3232
node.stop()
3333

3434

0 commit comments

Comments
 (0)