question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't interrupt a thread doing BRPOPLPUSH.

See original GitHub issue

I would like to be able to interrupt() a thread doing BRPOPLPUSH. Specifically, if nothing has been popped yet, I want jedis.brpoplpush() to be able to throw an InterruptedException, so the thread can die.

This has been a source of hangs in my program, so for the moment I’m working around this with a manual while { jedis.rpoplpush(); sleep(); } that is interruptible.

Specifically, if nothing has yet been popped (e.g., a work queue is empty), it would be good if the command could be interrupted.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:29

github_iconTop GitHub Comments

1reaction
Griefcommented, May 27, 2015

+1 for InterruptedException

0reactions
msdalpcommented, May 11, 2018

Is it expected behavior to get no exception at all when I am stopping a web app with tomcat stop.

public class MyContextListener implements ServletContextListener {
    private final DataListener RawListener = new DataListener();

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        RawListener.start();
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        RawListener.interrupt();
    }
}

On a jax-rs web app having this context with below Thread is not triggering any exception at all.

public class DataListener extends Thread {

    private boolean dataProcessOn;

    public DataListener() {
        super("DataListener");
        dataProcessOn = true;
    }

    @Override
    public void run() {
        while (dataProcessOn && !this.interrupted()) {
            try (Jedis redis = RedisPool.getJedis()) {
                final String baseData = redis.brpoplpush(
                        "rawdata:stream",
                        "ws:v1:rawdata:processing",
                        0);

                processData(baseData);
            }
        }
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't interrupt a thread doing BRPOPLPUSH. #493 - GitHub
I would like to be able to interrupt() a thread doing BRPOPLPUSH. Specifically, if nothing has been popped yet, I want jedis.brpoplpush() to ......
Read more >
Blocking Requests Interrupts - Google Groups
Since the thread blocks on brpoplpush/blpop waiting for a log event, when we stop the application we want to interrupt the blocking event...
Read more >
Why can't Thread.interrupt() interrupt a thread trying to acquire ...
Clearly, a synchronized block does not declare it, therefore it is impossible to interrupt a thread while it is waiting to acquire a...
Read more >
Pausing and interrupting threads | Microsoft Learn
Learn how to pause & interrupt threads in .NET. Learn how to use methods like Thread.Sleep & Thread.Interrupt, & exceptions such as ...
Read more >
How to Stop Threads in Java. Best Practices and Examples.
There's very little an external caller can do in this situation. (I cover non-standard cancellation at the end of this post.) Thread.Interrupt() ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found