Anthony Kong
Anthony Kong

Reputation: 40624

How to use twisted to structure this application?

I am in a situation that I need to tear apart an GUI application (written with wx and twisted, running on MS Windows), take out the core logic and deploy it as a cron job on a linux server that has no GUI environment.

I have replaced a number of wx.CallLater and wx.CallAfter with threading.timer. Apparently it does not work. The original code does not play well in the mulit-thread environment. It is probably because some underlying libraries are not thread safe. Threading also probably does not schedule jobs in the same manner as twisted.

So it is the typical workflow of the GUI app:

  1. User toggles a button to start up a real-time data reader (written in C)

  2. After toggle button turns green, it means the reader is up and running. User proceeds to switch between different real time data type

  3. When the new set of data becomes ready, user will start using other functions in the app.

My questions:

  1. How can I use twisted to recreate the above workflow? What tools in twisted allow me to wait for readiness of real-time data reader as mentioned in step 2?

  2. Will everything just 'happen' in the main thread?

Upvotes: 1

Views: 197

Answers (1)

Jean-Paul Calderone
Jean-Paul Calderone

Reputation: 48325

How can I use twisted to recreate the above workflow? What tools in twisted allow me to wait for readiness of real-time data reader as mentioned in step 2?

reactor.callLater - http://twistedmatrix.com/documents/current/core/howto/time.html

Will everything just 'happen' in the main thread?

Yes - http://twistedmatrix.com/documents/current/core/howto/reactor-basics.html

Upvotes: 1

Related Questions