First, sorry for the lengthy post. TLDR:? The sample code is a cut down, bare bones, test case meant to do nothing but tickle the inner-workings of TWS/IBGW 10.x in a way that highlights the core problem. It has no other purpose.
My personal real-world use case is more complex, naturally, but it doesn't make sense to share that code since it will certainly confuse the demonstration of the bug.
That said, it's not a big stretch to simply add some "useful" check of the tick-type (9 is a good example), print the price and then exit. Thus you get a program which prints yesterday's close... granted it's a basic program. But, it's important IMHO to focus on the bug itself. And, as you suggest, a bug is a bug so basic programs should work just as well as more complex ones. Indeed, if the most basic programs don't work then there's no solid foundation to build more complex programs.
Also, the sample code only requests delayed frozen data so it can be used with a trial account. That line can be deleted or commented; the problem will still occur.
As far as your suggestion to narrow down the scope goes, it is well-taken. I wish I could give additional insight as to what exactly triggers the problem. As mentioned earlier however, this sample code is as simplified as possible given the knowledge about the issue so far. Credit should go to IB support for providing the bulk of this example code as they've been helping me isolate the issue for the last four months. Thanks Andrew!
It's certainly possible there is some sequence of necessary events that can prevent the problem from occurring. Unfortunately, I don't know such a sequence and I have tried many types of things you suggest (sleeping here, exiting somewhere else, etc). If you (or anyone else for that matter) discover something of that nature, posting it would be hugely appreciated. Please feel free to leave comments on the github page as well.
You say...
I can certainly confirm that the normal usage of requesting non-delayed non-frozen data, making some sort of sensible use of the stream, and then disconnecting, works just fine with multiple clients either simultaneously or serially.
but, if you are using 10.x, I suggest you double and triple check. The test case as outlined on the github page works perfectly 100% of the time with TWS/IBGW 9x; not so with 10.x. Granted, using multiple clients in a serial (non-simultaneos) manner may not be common and so you could be mistaken in your certainty.
Actually following the instructions on the github page and exercising the test case precisely is the best indicator IMHO; again that is it's sole purpose. Also, if you really think your code is susceptible to this problem, run it against 9.x too... the ultimate problem is the client will hang indefinitely so it should be easy to spot. However, if you're running clients inside of the issue could be obscured.
Again, the problem only happens for clients that are
genuinely serial (i.e. non-simultaneos). If, e.g., you start one client, then another, exit the first, and start a third... the third won't have a problem. Testing has shown it's a resource acquisition issue and that TWS/IBGW internal data structures are not corrupted until *all* previous clients have disconnected and exited. Then, only when all the previous clients disconnect, the new client programs exhibit the problem.
It should go without saying that testing this should be done in a "clean room" environment. Although the problem exists in "live" real-money environments too, it's just wise to avoid using those during trading hours. That said, if you want to shut down all your software after hours, and give the test a go then I personally don't see a problem with that. I can't be held responsible for any catastrophies though ;-)
Hopefully I've addressed the concerns you have and helped clarify things a bit. If there's anything else don't hesitate to ask here, or on the github page.
P.S. Richard, if you haven't played at all with Python yet I encourage you to do so. Not just for working with TWS/IBGW but there's so much cool new development happening with it that it's definitely worth dabbling a little. I'm not sure what you mean by "not being equipped"... it should be really easy to install on any platform. In fact, most new Linux distributions come with it by default. But in case: https://www.python.org/downloads/