<div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">---------- Forwarded message ----------<br>From: "Dave Kirby" <<a href="mailto:D.Kirby@tideway.com">
D.Kirby@tideway.com</a>><br>To: <<a href="mailto:twisted-python@twistedmatrix.com">twisted-python@twistedmatrix.com</a>><br>Date: Mon, 25 Jun 2007 12:03:46 +0100<br>Subject: [Twisted-Python] Beginner question: integrating with CORBA
<br>
<div link="blue" vlink="purple" lang="EN-US">
<div>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I have just started looking at Twisted, and it looks really
cool and useful. I have read through much of the docs and the O'Reilly
book, but I still have a head full of questions.</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">First some background. I am considering using Twisted
to replace a component in a network management suite. All the components
communicate through CORBA (omniORB). The component I want to replace gets
CORBA calls that requests data from servers on the network, and the component retrieves
the data using ssh. Currently it spawns /usr/bin/ssh and uses pexpect to
control the interaction. Typically we will have 20-40 simultaneous calls
in progress to different IP addresses, each on a separate thread and each
spawning a separate ssh client.</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I want to replace this with a component that uses Twisted instead.
From what I have read Twisted should be ideal for this – I can use
the conch library to do the ssh calls and eliminate the need for spawning
dozens of separate processes (something that has been a major cause of bugs).</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">The first problem I have is how to integrate the omniORB
event loop with the reactor event loop. My initial thoughts are to have
the omniORB event loop in one thread and run the reactor loop in another
thread. When a CORBA call comes in it will use callFromThread() to post
a request to the Twisted thread that will create the connection and handle the
ssh session. Is this feasible? Any gotchas to watch out for?</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">However I have also seen reference to using threadedselectreactor
for mixing Twisted and foreign even loops (<a href="http://bob.pythonmac.org/archives/2005/04/17/twisted-and-foreign-event-loops/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://bob.pythonmac.org/archives/2005/04/17/twisted-and-foreign-event-loops/
</a>),
but I have no idea how to use this with omniORB. Is this worth
investigating further, or should I stick with my original idea?</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Replacing CORBA with the Twisted PerspectiveBroker is not an
option, since it would require extensively rewriting a dozen or so components.</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I have plenty of other questions, but will save them for another
time.</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">Dave Kirby</span></font></p>
</div>
</div><br></blockquote></div><br>I just got back into a similar thing today after about a month of inactivity on the issue. I posted about it here a while back but got no responses.<br>I'm trying to convert a simple Python/Omniorb CORBA Event Channel client script so that it can robustly handle a separate federated Name Service disappearing. I'm planning on running it using twisted for various reasons (common code, available functionality, etc). So I need to work out if I can use Twisted and CORBA (Omniorb to be specific) together, ideally within the same thread.
<br><br>Currently the simple script has a Tkinter UI which also registers a callback method with the Event Channel client wrapper to handle Event Messages. A self-rescheduling callback is also configured to drive the Orb, at some variable rate, and then the script is handled by the Tkiner mainloop. At regular intervals the Orb is run then rescheduled and then control is returned back to the Tk mainloop. I'm at home and can't remember the exact code but something along the lines of:
<br><br>def runOrb(self):<br> if self.orb.work_pending():<br> self.orb.perform_work()<br><br>This all seems to work well. However the script is fairly simple in that it's only monitoring and reacting to Event Channel messages, so slightly different from your use. However, I think that it demonstrates that the orb can be run from within another event processing loop within the same single thread - in this case the Tk mainloop.
<br>Now the Tk event processing can be handled by the tksupport package so I thought why not use that model for a CORBA support package?<br>I've totally copied the tksupport file (it's very small) and converted it to perform the running and re-scheduling of the CORBA orb.
<br><br>Sorry I can't provide you more info but as mentioned above I only got back into this today (no testing yet) plus I finish work at that company in a few days. If I get anywhere I'll post back some info. Hopefully it gives you something to look into.
<br><br>Regards,<br>Chris Laws<br>