Commit Graph

1450 Commits

Author SHA1 Message Date
mhchia
ddbedc6c15
Pubsub: handle_talk
- Change from async function to sync
- Change the name to `notify_subscriptions`, which is clearer.
2020-02-05 21:44:33 +08:00
mhchia
5b03a7ad9f
Mplex: only close the send of new stream channel 2020-02-05 21:41:28 +08:00
mhchia
b7c2ec2187
Mplex: change the reference url
To the commit hash, to make it more correct.
2020-02-05 21:31:04 +08:00
mhchia
7f8c0f11f6
Pubsub: change channel size
To `32` to conform to the go implementation.
2020-02-05 21:30:26 +08:00
mhchia
ba0fb8a833
Fix: use pass over ...(Ellipse)
Use `...`(Ellipse) only in abstract methods.
2020-02-05 20:36:42 +08:00
mhchia
1fff6ad6b4
Mplex: change message channel size to 8
To avoid infinity sized channel, and to conform to the go
implementation.
2020-02-05 20:31:18 +08:00
mhchia
64c9c48dac
Mplex: change new stream channel size
To `0`, i.e. no unbuffered, to avoid growing buffer size.
2020-02-05 19:48:02 +08:00
mhchia
1e7d5c73ee
test_mplex_stream: refactor 2020-02-05 17:25:39 +08:00
mhchia
996b5cf15d
Mplex: catch exceptions from channel.send 2020-02-05 17:05:30 +08:00
mhchia
12cb0d9ac4
Swarm: change notify_xxx back to async func 2020-02-04 22:56:13 +08:00
mhchia
13930ae718
SwarmConn: perform close right away
In `_handle_new_streams`, when the underlying muxed conn is unavailable,
close `SwarmConn` itself right away, to reset all the streams.
Therefore, the stream processed by `_handle_muxed_stream` are conscious
of the fact that they are reset. It allows a more graceful clean up.
2020-02-04 22:51:21 +08:00
mhchia
c0ab609559
Mplex: catch RawConnError when writing
Also, do nothing in `MplexStream.reset` if `MuxedConnUnavailable` is
raised when sending the message.
2020-02-04 21:57:59 +08:00
mhchia
f884bfa39e
SwarmConn: don't access Swarm.manager
Open a local nursery instead.
2020-02-04 21:57:11 +08:00
mhchia
0548d28568
Fix: StreamReset in the stream handlers
Since we don't catch `Exception` in the stream handlers, catch them in
the stream handlers in the tests.
2020-02-04 20:46:40 +08:00
mhchia
a7ba59bf9f
Add a nursery in Swarm
To avoid using the one in `Service`
2020-02-04 20:45:58 +08:00
mhchia
b007bb4d07
Use the latest async-service 2020-02-04 17:46:30 +08:00
mhchia
89338914d3
Add comment for serve_tcp 2020-02-04 17:45:56 +08:00
mhchia
857bb34f4e
Add checkpoints in PubsubNotifee
Since some of the methods in `PubsubNotifee` are doing nothing,
add checkpoints to yield control.
2020-02-04 17:45:37 +08:00
mhchia
66975ae3f2
Pubsub: change run_task to run_daemon_task 2020-02-04 17:43:39 +08:00
mhchia
7ae9de9002
Fix handler in net_stream_pair_factory
Change it to async function. It wasn't discovered since we caught all
exceptions raised in stream handlers.
2020-02-04 17:09:26 +08:00
mhchia
3a91f114ab
Swarm: add default_stream_handler
Advantage:
- To avoid `None` checks
- If users forget to register a stream handler for `Swarm`,
with the default stream handler, opened streams aren't removed
until `Swarm` finishes.
2020-02-04 17:05:53 +08:00
mhchia
3fc60cb312
SwarmConn: iterate streams.copy in _cleanup
To avoid `RuntimeError` if `streams` is changed.
2020-02-04 17:04:28 +08:00
mhchia
d483982acb
SwarmConn: don't catch exceptions in handler 2020-02-04 15:10:49 +08:00
mhchia
5da102d1c9
Ping protocol: move with statement out of try 2020-02-04 15:09:42 +08:00
mhchia
113696dce2
TravisCI: use python 3.7 instead of 3.7-dev 2020-02-03 16:04:32 +08:00
mhchia
22963a3099
Fix trio-typing>=0.3,<0.4
To be consistent with trinity
2020-02-02 18:18:01 +08:00
mhchia
05d5d045ea
Fix pubsub interop: missing unsubscribe_fn 2020-02-02 18:17:22 +08:00
mhchia
1588be2be9
Change the channel size of peer queue
Back to `0`, to avoid unlimited buffer size.
2020-01-31 17:42:47 +08:00
mhchia
e57d01f360
PR feedback
- Use f-string
- Fix wrongly indented comments
- Add dep `trio-typing`
2020-01-28 15:48:41 +08:00
mhchia
095a848f30
Add clean-up logics into TrioSubscriptionAPI
Register an `unsubscribe_fn` when initializing the TrioSubscriptionAPI.
`unsubscribe_fn` is called when subscription is unsubscribed.
2020-01-28 00:29:05 +08:00
mhchia
c3ba67ea87
Remove locks in PubsubNotifee
- Change `open_memory_channel(0)` to `open_memory_channel(math.inf)`, to
avoid `peer_queue.send` and `dead_peer_queue.send` blocking. This allows
us to remove the locks.
- Only catch `trio.BrokenResourceError`, which is caused by Pubsub when
it's closing.
2020-01-27 14:30:44 +08:00
mhchia
92ea35e147
Fix IPubsub and add IPubsub.wait_until_ready 2020-01-27 00:10:33 +08:00
mhchia
e3a1dd62e4
Use new type hinting for trio channel 2020-01-26 23:56:19 +08:00
mhchia
42bc4d5d06
INetworkService implement ServiceAPI 2020-01-26 23:55:31 +08:00
mhchia
ddfbf9ffc8
Use raise from to reserve stacktrace 2020-01-26 23:54:29 +08:00
mhchia
b85bab1a09
Don't catch trio.BusyResourceError 2020-01-26 23:09:56 +08:00
mhchia
5b4b65faa8
Change default value of read()
From `n = -1` to `n = None`, to comply with trio API
2020-01-26 23:03:38 +08:00
mhchia
6e01a7da31
PR feedback: async with host.run() 2020-01-26 16:44:42 +08:00
mhchia
dcc4aa52fc
Merge branch 'master' into feature/porting-to-trio 2020-01-19 16:56:40 +08:00
mhchia
f0c4254bbd
Use Service instead of ServiceAPI
To fix error with async-service==0.1.0a5
2020-01-18 00:31:39 +08:00
mhchia
6c7aa30191
Add events in Pubsub
To ensure `handle_peer_queue` and `handle_dead_peer_queue` are indeed
run before the tests finish. Previously, we get errors when performing
`iter_dag` after cancellation. This is because `handle_peer_queue` or
`handle_dead_peer_queue` is not actually run before the Service is
cancelled.
2020-01-18 00:17:30 +08:00
mhchia
54871024cc
Pin the version of async-service to a4 2020-01-16 18:54:19 +08:00
mhchia
eef241e70e
Make Mplex and SwarmConn not Service
After second thoughts, they seem not a good candidate of `Service`.
The shutdown logic becomes simpler by making them not `Service`.
2020-01-07 21:50:03 +08:00
mhchia
eab59482c0
Use the real get_unused_tcp_port
To get rid of the fake one
2020-01-07 16:45:59 +08:00
mhchia
45eeb4fba3
Change notify_xxx to sync functions
Since we already have `Swarm.run_task`, we can just change notify
functions to sync.
2020-01-07 16:45:06 +08:00
mhchia
4db043a26a
Remove pexpect from tox 2020-01-07 16:23:00 +08:00
mhchia
52f85586b8
Fix docs 2020-01-07 15:41:44 +08:00
mhchia
fe4354d377
Fix tests_interop
- Remove pexpect
- Use new version of `p2pclient`, which makes use of anyio
- Clean up tests
2020-01-07 14:14:34 +08:00
mhchia
000e777ac7
Try older async-service 2019-12-26 20:44:58 +08:00
mhchia
94f0fcb6ad
Iterate dead_peer_receive_channel with async for 2019-12-26 20:44:32 +08:00