[Quickfix-developers] QuickFIX Python and Twisted
Brought to you by:
orenmnero
|
From: Robert P. <rob...@gm...> - 2006-11-15 18:41:20
|
HI Folks, I'm trying to build a simply gateway based on QuickFIX with the python bindings, and the Twisted framework (http://twistedmatrix.com). I'm finding some kind of threading issue. My aim is to wrap the quickfix engine with a simple RPC container, so that one can connect to the daemon and invoke calls like "start", "stop", "subscribe to data" etc. The twisted framework provides an asynchronous networking layer to do so. However things seem to lock up when I invoke the SocketInitiator.start() method. I can start up the service, and create the QuickFIX application, and setup and configure the various QuickFIX components, ala: class MyQFService: def __init__ settings = quickfix.SessionSettings(configFile) application = MyQFClient(connStr) storeFactory = quickfix.OdbcStoreFactory(settings) logFactory = quickfix.OdbcLogFactory(settings) self.quickfixSettings = settings self.quickfixApplication = application self.quickfixStoreFactory = storeFactory self.quickfixLogFactory = logFactory self.quickfixInitiator = quickfix.SocketInitiator(application, storeFactory, settings, logFactory) When a remote "START" command is issued, the main thread of the twisted code calls the SocketInitiator to start the QuickFIX thread: def startQF(self): log.msg("QuickFIX Engine starting.") self.quickfixInitiator.start() log.msg("QuickFIX Engine started.") return defer.succeed("STARTED") At this point, the quickfix engine thread starts, and I see logon, heartbeats, and other admin messages. The log message immediately after the start() call executes, and returns correctly. However, the main thread of the Twisted application seems to block entirely, and I don't get any response from the application on subsequent RPC attempts. At this point the appliction also stops responding to Ctrl-C on the command line, when before it would gracefully terminate. It seems as if the quickfix thread has taken over, or more likely is completely blocking the main twisted thread. Any thoughts on what might be happening here? My first guess is that it has to do with logging, but I can't be sure. thanks for any insight, rob |