Skip Menu |

This queue is for tickets about the Finance-InteractiveBrokers-SWIG CPAN distribution.

Report information
The Basics
Id: 79926
Status: resolved
Worked: 15 min
Priority: 0/
Queue: Finance-InteractiveBrokers-SWIG

People
Owner: Nobody in particular
Requestors: tripp [...] wasteoftime.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 0.01_01
  • 0.01_02
  • 0.02
  • 0.03
  • 0.03_03
  • 0.04
  • 0.04_01
  • 0.05
  • 0.06
  • 0.06_01
  • 0.07
  • 0.08
Fixed in: 0.10



Subject: Select waiting/blocking while waiting for messages
Date: Fri, 28 Sep 2012 21:13:19 -0500
To: bug-Finance-InteractiveBrokers-SWIG [...] rt.cpan.org
From: Tripp Donnelly <tripp [...] wasteoftime.org>
I'm a hack programmer at best, so if I'm way off, please let me know. It seems like when you call processMessages() it blocks for a very long time if no messages are coming in. I possibly want to do something during this time. So I changed the timeout specificly for the select in the processMessages function to wait only a second. I don't quiet understand what you're doing with the ping deadline and such, so maybe I'm just missunderstanding the situation.
On Fri Sep 28 22:13:30 2012, tripp@wasteoftime.org wrote: Show quoted text
> I'm a hack programmer at best, so if I'm way off, please let me know. > > It seems like when you call processMessages() it blocks for a very long > time if no messages are coming in. I possibly want to do something during > this time. So I changed the timeout specificly for the select in the > processMessages function to wait only a second. > > I don't quiet understand what you're doing with the ping deadline and
such, Show quoted text
> so maybe I'm just missunderstanding the situation.
Hi, thanks for using F::IB::SWIG! You're reading it right, there is a pretty long delay. It's intended to be a (mostly) blocking "wait for messages" call, but it has a timeout explicitly to send the pings required by the IB protocol. In fact, if you look at the tws_api code, you'll see that that method is mostly just a pared-down version of their own call. In my own implementation I only use the IB client as a daemon, and don't react to the events directly (except through a distributed message queue), and do my "other" concurrent activities separately. Other mechanisms include multithreading, etc. If you need the shorter timeout for your application, it sounds like you've got it sorted. I'll leave this open, as I may add an optional constructor argument or other mechanism in the future to introduce a programmable delay or non-blocking processMessages call once I have a chance to think through the best way of doing it.
Show quoted text
> You're reading it right, there is a pretty long delay. It's intended to > be a (mostly) blocking "wait for messages" call, but it has a timeout > explicitly to send the pings required by the IB protocol. In fact, if > you look at the tws_api code, you'll see that that method is mostly just > a pared-down version of their own call. > > I'll leave this open, as I may add an optional constructor argument or > other mechanism in the future to introduce a programmable delay or > non-blocking processMessages call once I have a chance to think through > the best way of doing it.
Finally got around to adding a configurable delay in 0.10, up on CPAN now. Once you create the FIBAPI object, the setSelectTimeout($float_seconds) method can reset the timeout. Setting it to 0 should create a non-blocking select() call, which will return immediately, if that's desired.