Skip to content

Feedback from Vorner #206

Closed
Closed
@yoshuawuyts

Description

@yoshuawuyts

Vorner wrote a really insightful post on trying out async/await with async-std, and talked about several things that didn't go well. This is a tracking issue to address all the feedback provided.

Also @vorner if you're reading along; thanks so much for the writeup! -- Posts like these are incredibly helpful, and allow us to learn where we need to improve.

Items

Quotes

But when running it, with both server and client on localhost, sometimes the experiment never finished, even with low rates of new connection creation. This seemed odd.


Still, even with rates like 100 new connections per second, some of the connections were timing out.

Code Example

// expected
async fn connect(server: SocketAddr, content: Arc<[u8]>, mut results: Sender<Duration>) {
    let res = timeout(connect_inner(server, content), TIMEOUT).await.unwrap();
    res.send().await.unwrap();
}

// current
async fn connect(server: SocketAddr, content: Arc<[u8]>, mut results: Sender<Duration>) {
    let connect = connect_inner(server, content);
    pin_mut!(connect);
    let timeout = task::sleep(TIMEOUT);
    pin_mut!(timeout);
    match future::select(connect, timeout).await {
        Either::Left((Ok(duration), _)) => results
            .send(duration)
            .await
            .expect("Channel prematurely closed"),
        Either::Left((Err(e), _)) => error!("Connection failed: {}", e),
        Either::Right(_) => {
            warn!("Connection timed out");
            results
                .send(TIMEOUT)
                .await
                .expect("Channel prematurely closed");
        }
    }
}

Refs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions