Giter Site home page Giter Site logo

Comments (12)

nihohit avatar nihohit commented on July 30, 2024

I'm sorry, but it would be hard to help here without compiling code. Can you provide a full example?

from redis-rs.

jayeshpk1 avatar jayeshpk1 commented on July 30, 2024

Thanks. updated the code

from redis-rs.

nihohit avatar nihohit commented on July 30, 2024

no, this still won't compile - what are all the mods you're referencing? can you create a sample repository, or better yet, recreate this in redis-rs' tests?

from redis-rs.

nihohit avatar nihohit commented on July 30, 2024

and I hope it's clear - you're referencing 4 mods here. If they're large, we won't go over them to find your bug. Please post a minimal sample repository.

from redis-rs.

jayeshpk1 avatar jayeshpk1 commented on July 30, 2024

This example has rest of the code https://github.com/paoloposso/rust_redis_pubsub/tree/main/src

from redis-rs.

nihohit avatar nihohit commented on July 30, 2024

ok, what am I supposed to see in this code example? how does it demonstrate the issue?

I see 3 messages published, and that 3 messages are printed to console with "published" printed somewhere in-between. This is expected. Then the program hangs, because redis_subscrober spawned a task that never completes.
I also see that you create a new connection for each published message, which isn't an optimal usage of resources.

What issue does this demonstrate?

from redis-rs.

jayeshpk1 avatar jayeshpk1 commented on July 30, 2024

Please publish the messages in a loop of 100,000 and run.

from redis-rs.

nihohit avatar nihohit commented on July 30, 2024

which loop? there's no loop in main.rs.

from redis-rs.

jayeshpk1 avatar jayeshpk1 commented on July 30, 2024

you can see the loop in the main.rs I posted above

from redis-rs.

nihohit avatar nihohit commented on July 30, 2024

You're right, this does reproduce as given. But, when I removed the serde dependency, this doesn't reproduce - I ran the code to 600K operations, and counting.
Why do you think this is an issue with the redis crate?

from redis-rs.

nihohit avatar nihohit commented on July 30, 2024

Sorry, I made a mistake - the example still gets stuck at the end of the loop, regardless of how large the loop is - probably because of the spawned task that never completes. Once I changed the spawned task to complete with

pub fn subscribe(channel: String) -> Result<(), Box<dyn Error>> {
    let _ = tokio::spawn(async move {
        let client = redis::Client::open("redis://localhost").unwrap();

        let mut con = client.get_connection().unwrap();
        let mut i = 0;
        let _: () = con
            .subscribe(&[channel], |msg| {
                i += 1;
                let received: String = msg.get_payload().unwrap();

                println!("{received}");

                return if i == 157126 {
                    ControlFlow::Break(())
                } else {
                    ControlFlow::Continue
                };
            })
            .unwrap();
    });

    Ok(())
}

the application completed successfully.

from redis-rs.

nihohit avatar nihohit commented on July 30, 2024

@jayeshpk1 was your issue solved? can this issue be closed?

from redis-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.