Comments (9)
Could you please provide a minimal code example that reproduces the bug?
Please provide as many details as possible, otherwise it's hard to help you.
from chan.
Can I give you a link to the entire repository? ( https://github.com/szagi3891/testhttp , branch "process")
In the evening I will try to extract a small piece of code.
from chan.
I really don't have the time to be looking through an entire repository of code. If there's a bug in chan
, then I'd really prefer to see a small piece of code that I can run that reproduces the problem you're experiencing.
from chan.
Sure. In the evening I will try to prepare a small piece of code.
from chan.
I create test repo width minimal code.
Enough to do :
git clone https://github.com/szagi3891/test_chan_bug
cd test_chan_bug
cargo run
I get output :
grzegorz@grzegorz:~/Pulpit/rust/testchan$ cargo run
Running `target/debug/testchan`
Hello, world!
before send
^CTermination signal catched.
grzegorz@grzegorz:~/Pulpit/rust/testchan$ Shutting down!
grzegorz@grzegorz:~/Pulpit/rust/testchan$
grzegorz@grzegorz:~/Pulpit/rust/testchan$ cargo run
Running `target/debug/testchan`
Hello, world!
before send
worker 1: get value rx_request Some("simple value1")
^CTermination signal catched.
grzegorz@grzegorz:~/Pulpit/rust/testchan$ ./target/debug/testchan
Hello, world!
before send
^CTermination signal catched.
Shutting down!
grzegorz@grzegorz:~/Pulpit/rust/testchan$ ./target/debug/testchan
Hello, world!
before send
^CTermination signal catched.
Shutting down!
grzegorz@grzegorz:~/Pulpit/rust/testchan$
grzegorz@grzegorz:~/Pulpit/rust/testchan$
grzegorz@grzegorz:~/Pulpit/rust/testchan$ ./target/debug/testchan
Hello, world!
before send
^CTermination signal catched.
Shutting down!
grzegorz@grzegorz:~/Pulpit/rust/testchan$
grzegorz@grzegorz:~/Pulpit/rust/testchan$
grzegorz@grzegorz:~/Pulpit/rust/testchan$ ./target/debug/testchan
Hello, world!
before send
worker 9: get value rx_request Some("simple value1")
worker 7: get value rx_request Some("simple value2")
after send
before send
^CTermination signal catched.
Shutting down!
grzegorz@grzegorz:~/Pulpit/rust/testchan$
Code stops when we pass the data on channel tx_request.
Sender should never pause because the channel is asynchronous.
println!("before send");
tx_request.send("simple value1");
tx_request.send("simple value2");
tx_request.send("simple value3");
println!("after send");
from chan.
description is good? I left only a small piece of code that deals with the problem.
from chan.
@szagi3891 Yes, thank you! I was able to trim it down to this:
#[macro_use]
extern crate chan;
use std::io;
use std::thread::{self, JoinHandle};
use std::time::Duration;
fn main() {
println!("Hello, world!");
let (send1, recv1) = chan::async();
thread::spawn(move || {
loop {
println!("before send");
send1.send("simple value1");
send1.send("simple value2");
send1.send("simple value3");
println!("after send");
thread::sleep(Duration::from_millis(50));
}
});
let (_send2, recv2) = chan::async::<String>();
for i in 0..30 {
let recv1 = recv1.clone();
let recv2 = recv2.clone();
spawn(format!("worker {}", i), move || {
println!("starting worker {}", i);
loop {
chan_select! {
recv1.recv() -> val => {
println!("worker {}: get value recv1 {:?}", i, val);
},
recv2.recv() -> val => {
println!("worker {}: get value recv2 {:?}", i, val);
}
}
}
}).unwrap();
}
chan_select! {}
}
fn spawn<F, T>(name: String, block: F) -> io::Result<JoinHandle<T>>
where F: FnOnce() -> T + Send + 'static, T: Send + 'static {
thread::Builder::new().name(name).spawn(block)
}
My thinking right now is that it probably is indeed a bug. My guess is that chan_select!
is for some reason not releasing a lock that all channels must acquire when sending values.
For what it's worth, I would, in general, recommend using synchronous channels, with a buffer if needed. (That doesn't help in this case though, since it looks like synchronous channels are affected too.)
from chan.
Thank you. And is there a chance that it will somehow fix soon?
from chan.
Clever amendment :)
I did own implementation channels (no macro select).
https://github.com/szagi3891/channels_async-rs
from chan.
Related Issues (19)
- remove hyper dev dependency HOT 4
- Possible memory leak in `tick` HOT 2
- [feature request] re-expose try_recv() HOT 8
- How to chan_select over multiple chans that will terminate? HOT 1
- Using chan_select! requires values to be 'static HOT 3
- Add timeout-able methods HOT 1
- doesn't seem to work with `fork()` HOT 2
- Select integration with std lib mpsc api HOT 4
- Allow chan_select to generate no-op None variants HOT 2
- Sender::send(t) -> Result<(), SendError> HOT 16
- Deadlock with select-send and select-recv HOT 2
- crossbeam-channel – EOL chan HOT 6
- Broadcast to all consumers HOT 4
- Return value from `chan_select!` expression HOT 2
- chan::async() conflicts with Rust 2018 Edition HOT 6
- I think it's butter to return a Result for invalid add HOT 5
- Relicense under dual MIT/Apache-2.0 HOT 8
- All Notifier subscriptions made in select.rs appear to be leaked HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chan.