Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IB Disconnection #28

Open
vinceyap88 opened this issue Jul 25, 2016 · 5 comments
Open

IB Disconnection #28

vinceyap88 opened this issue Jul 25, 2016 · 5 comments

Comments

@vinceyap88
Copy link

vinceyap88 commented Jul 25, 2016

I have noticed that there are some threads running after calling the InteractiveBrokersClientInterface.unsubscribeLevel1() method as well as
InteractiveBrokersClientInterface.disconnect(). Are there any methods which can be used to close the running threads after the connect() method and subscribeLevel1() method?

@rterp
Copy link
Owner

rterp commented Jul 28, 2016

There is a thread running to process the internal queue of IB data from the level 1&2 subscribers, and order events. Is there an issue with these threads continuing to run even if there are no current level 1 subscribers?

@vinceyap88
Copy link
Author

The program need to have proper exit. In order to exit properly, we need to stop the running threads. Is there anyway to stop it?

@rterp
Copy link
Owner

rterp commented Jul 28, 2016

I see. Probably the easiest thing to do will be to convert the threads to daemon threads, so if they are still running when the main thread stops, the application will shut down without needing to stop the daemon threads.

@charlye
Copy link

charlye commented Oct 12, 2016

Hi Rob,

I think what Vince mentioned was partly caused by blocked threads in IBQuoteProcessor.

    public void run() {
        while( shouldRun ) {
            try {
                processData( quoteBlockingQueue.take() );
            } catch( Exception ex ) {
                //logger.error(ex, ex);
                ex.printStackTrace();
            }
        }
    }

When stopProcessor() method was called, shouldRun is changed to false with intention to exit the while loop, but the thread could be permablocked if no new data is put into the queue. I suggest to also interrupt this thread in stopProcessor()

@rterp
Copy link
Owner

rterp commented Oct 23, 2016

Ok, I see what you are saying now. You're right, if you aren't subscribed to any quotes, or if its after market hours and no quotes are coming in. The other option would be to use the
poll(long timeout, TimeUnit unit) on the blockingQueue rather than take(), and give it a 500ms or so timeout value, so if there was nothing in the queue, the operation would timeout, it would see shouldRun is false, and exit the loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants