hi there, folks:
I'd really like to release 0.7.0 but I would like it to be at least a
little bit tested before I do so. Could those of you with CVS trees check
everything out and see if it performs as advertised? Deeper bugs than
that will have to wait for the next release, but I'd at least like to know
if it works for someone other than me.
______ __ __ _____ _ _
| ____ | \_/ |_____] |_____|
|_____| |_____ | | | |
@ t w i s t e d m a t r i x . c o m
On 18 May 2004, the following message was posted to this mailinglist:
Jp Calderone exarkun at divmod.com wrote:
>Daniel Newton wrote:
> I have a simple XML-PRC server similar to the example below:
> from twisted.web import xmlrpc, server
> class Example(xmlrpc.XMLRPC):
> """An example object to be published."""
> def xmlrpc_add(self, a, b):
> """Return sum of arguments."""
> return a + b
> if __name__ == '__main__':
> from twisted.internet import reactor
> r = Example()
> reactor.listenTCP(7080, server.Site(r))
> I want to be able to get the address of the client that calls the
> method can anyone help me with this?
This solution didn't work because 'transport' isn't a property of the
I'm currently in the process of changing from a customized
SimpleXMLRPCServer to a twisted XMLRPC server solution and I need to
insert the client IP into the attributes passed to the called xmlrpc
method. Anyone who knows the answer and is willing to share the info?
I'm using Twisted 1.3.0 on python2.4 on an Ubuntu-Hoary x86 Linux box.
I'm using twisted and spawnProcess() with a Queue structure to chain
processes that need to be called (specifically, imagemagick commands).
I use the "processEnded" event/method of t.i.p.ProcessProtocol to go
from one task to the next. Twisted shares a python process with a
multi-threaded web-app-kit (Webware) so it has to be run in a thread.
This worked well on other older versions of twisted and older versions
of python; also on linux. I've tracked down the problem to be twisted
itself (or my incorrect use of it) rather than my code. This example
from twisted.internet import reactor
from twisted.internet.protocol import ProcessProtocol
class MyProt( ProcessProtocol ):
def processEnded(self, reason):
print "ended.", reason
executable = '/bin/touch'
args = ( '/tmp/foo.txt', )
args = (executable,) + tuple(args)
reactor.spawnProcess( MyProt(), executable, args )
reactor.callLater( 5, reactor.stop )
As is, this code never runs the "processEnded()" method of MyProt().
If I change the reactor.run() parameter to leave the signal handlers
on, it works.
Note that I need to leave the signal handlers turned off because I
can't run the reactor in the main thread; Webware needs that.
I also know that the subprocess is giving up its file descriptors; I
can see that if I put more print statements into MyProt(). And I know
that the subprocess is working; /tmp/foo.txt is there.
It seems that somehow the reactor is using signals to notice when a
process has ended; this makes a certain ammount of sense intuitively,
though I don't understand the nitty-gritty of processes and signals at
all. And more importantly, this has worked before on other
combinations of twisted/python.
Is this a bug? If so, has it been fixed? If not, what should I do to
detect when a spawned process is finished?
Thanks very much. Twisted rocks.
I have a couple of services. The second is dependent on the first being
fully initialised before the second gets set up.
I thought that the order of Service startup was typically handled by
organising services in a hierarchy, and that the startup of the
hierarchy understood deferreds. I was wrong - service.Application is a
MultiService and only understands deferreds in stopService.
There's a DependentMultiService class in twisted.internet.app but that
entire module has been deprecated.
Is there a reason why the MultiService does not support deferreds in
Is there a reason that DependentMultiService was not moved across to the
In other words, what is the recommended way of starting services in the
correct order, including waiting for them to get initialised fully,
/ \__ Matt Goodall, Pollenation Internet Ltd
\__/ \ w: http://www.pollenation.net
__/ \__/ e: matt(a)pollenation.net
/ \__/ \ t: +44 (0)113 2252500
/ \ Any views expressed are my own and do not necessarily
\__/ reflect the views of my employer.
wxreactor in Twisted 2.1 uses threadedselectreactor. This means that wx
apps ought to use wxreactor, not TSR directly; there are some issues
with vanilla TSR wx integration that are also present in wxreactor, but
will be fixed in future versions of wxreactor.
What's broken (there may be more):
1. reactor shutdown events aren't handled correctly (e.g. Deferred
returned from during-shutdown event).
2. Signal handling for e.g. Ctrl-C is caught by wx, not twisted.
In order to get these fixed I need your help. I have a version of
wxreactor that *probably* fixes these in Subversion trunk. You can try
it out by running doc/core/examples/wxdemo.py. Hitting Ctrl-C, choosing
Exit from the menu or closing the menu all should have the same effect -
the application logs "shutting down in 0.3 seconds...", "2", "1", "0"
then exits. In addition, "Hello world" should continue to be printed
while the dialog box is open or you are holding down a menu.
Please try this out, and report success or failure at
<http://twistedmatrix.com/bugs/issue1235>. I'm especially interested to
hear if it works on Windows or Mac OS X. Please include your OS and
version of wxPython/wxWidgets when submitting reports.
In an application I'm writing I would like all Perspective Broker
clients to share some list of objects and have them all keep in sync
when one of the clients updates an object's attributes (imagine say a
shared address book - I'm not creating an address book, but it's
easier than explaining the details of my app). I've created a
pb.Cacheable class for the purposes of notifying clients when new
objects are added to this list which works fine (I based this on the
cache_classes.py example from the docs here <http://twistedmatrix.com/
Where I am having trouble is with round trip editing these objects
(which are all both pb.Copyable and pb.RemoteCopy - I did this so
that I wouldn't have problems of accidentally storing a RemoteFoo
object in my ZODB rather than a Foo object). Say one user edits one
of the objects (e.g. changes the name/phone number etc. of one of the
entries in the shared address book). and then I callRemote to some
method like "updateObject" on the users Avatar and pass this object
to this method. According to the doc page I mentioned previously
"Copyable objects return unchanged from a round trip", but when I
check if the object is in the list on the server it thinks it isn't
there. In fact, they seem to point to different objects in memory, so
naturally a "if object in list" statement will fail.
Am I checking for equality in the wrong way? Or am I approaching the
problem in the wrong way?
I am quite new to Twisted, so I apologise if the problem is obvious.
Preface: I'm not a protocol guru, or even a "distributed object" (DO)
guru, so this message is from the point of view of a DO novice looking for
insights from some of the twisted minions (/gurus) and other cybergods
who hang out here.
I've been monitoring Brian's work on newpb (PBng?), and I love
everything about it. Except how long it's taking. :(
Brian: I know you have a real job, too, so I completely understand!
(Incidentally, you're the only one whose commit messages I save,
because they're always so well documented.) I've read the TODO list,
and pretty much everything is beyond my abilities (and time) to
contribute to -- sorry! -- but is it possible to put any kind of
approximate timeline on some of it?
PB is what I really want to use for my project, but I need something
that's close to ready-for-prime-time, and I've been waiting literally
years for PB, so in the meantime I'm looking at other candidates.
I would definitely prefer a "twistable" technology -- i.e., one for
which some kind of async adapter can be written from twisted -- and
also one that has bindings for other languages (mainly Java, since
my organization is Java-heavy).
I've dismissed the idea of CORBA -- although one or more
of the python orbs is probably twistable, CORBA has such a negative
image that I'd probably have to lie about using it, and it does
have lots of weird baggage.
[Aside: I always liked Bill Janssen's ILU (how could you not like a
distributed object system that had bindings for both python and
lisp??) and I was sad to see it go. Interesting that Bill is
now in the Python community.]
Over the weekend I read the docs for ICE (http://www.zeroc.com/),
sort of a streamlined, WAN-optimized CORBA. It has nice features,
and even support for (threaded) async operations which seems
(to my novice understanding) twistable. But its type system and
python binding seem very unpythonic to me, based on lots of C++-isms,
I just today discovered "json-rpc", which looks pretty cool.
I currently use xml-rpc in my twisted app, and I've thought that
json would be a neat replacement for xml (more concise + very
pythonic syntax so probably *way* more efficient python
marshalling/unmarshalling). And someone finally did it -- great!
Has anyone here experimented with it? Anyone thought
about twistifying it? If not, I might take a stab (I'd start
by looking at what Itamar [I think] did with xml-rpc).
The dialogue copied below shows yet another example of the frustrations
that arise when trying to bridge the chasm between Twisted and the
synchronous rest of the world.
This latest episode inspired the idea of a synchronous code fishbowl
that offers well-behaved Twisted code a deferToQueue() method for
running badly-behaved blocking code.
- Ed Suominen
-------- Original Message --------
Michael Bayer wrote:
> why are you using twisted *with* threads ? didnt we all agree that was
> sort of unnecessary ?
Twisted operates without needing to run *in* a thread by doing
everything asynchronously. Every call made via the Twisted event loop
must either return (synchronous) results very quickly or return an
immediate reference to an eventual result (thus operating
asynchronously). The objects that hold those immediate references are
called "deferreds" in TWisted parlance.
Twisted runs most all of its internal operations with appropriate
chunking and use of select() to keep the asynchronous event loop humming
along nicely, but it has no control over how other libraries do things.
When an external library like SQLAlchemy presents a blocking call like
select(...).execute.fetchall(), the only way to make that call "play
nice" with Twisted by immediately returning a deferred to the eventual
result is by having TWisted run it in a thread. It includes the
deferToThread() function for that express purpose.
> (this goes to my point that twisted is a pain in the butt...)
Perhaps, but asynchronous code is a whole different way of thinking that
some of us actually find cleaner and more intuitive than blocking +
threads. What I'm trying to do with sAsync is put the "pain in the butt"
associated with making synchronous and asynchronous code work together
firmly behind the scenes for Twisted users, at least as far as
interacting with SQLAlchemy is concerned.
> anyway, SA 0.2 uses the same idea for sqlite threading as 0.1....it
> maintains each connection thread locally since you cant share a sqlite
> connection between threads. im also not sure what youre talking about
> with a "thread local copy of the engine", if thats something youre doing
> on your end, you might want to not do that. use Connection objects
> instead theyre much more portable.
Mike, I remember you telling me a while ago that SA somehow figures out
how to make things work with the engine. That was after I spent a lot of
time trying to re-engineer the wheel, to great frustration on my part. I
followed your advice, ditched my thread-local code, and got SA
transactions just fine (based on the engine) to run in arbitrary
threads. Now it's not working in SA 0.2. Could you point out what's
changed in regard to the engine vs. threads vs. sqlite?
I'd rather not change everything under the hood (e.g., using connections
somehow) if I don't have to. The lesson of not trying to re-engineer
what SA handled fine on its own is still with me. :-)
Best regards, Ed
> On May 27, 2006, at 6:57 PM, Ed Suominen wrote:
>> My sAsync project relies on Twisted to maintain a thread pool. It runs
>> database transactions in some available thread via Twisted's
>> deferToThread() function. See the transact function in
>> http://foss.eepatents.com/sAsync/browser/trunk/sasync/database.py for
>> That arrangement created no problem with SQLite and SA 0.1, even though
>> SQLite does not allow sharing of connections between threads. Somehow,
>> SA 0.1 made the transaction run in its thread with a thread-local copy
>> of the engine and table that was created in the main thread. I never
>> figured out how, but it just worked.
>> It doesn't work in SA 0.2, however. I either get the error when trying
>> to use the main-thread table in the threaded transaction, or have no
>> table available in the thread because it wasn't created there. Now I'm
>> trying to figure out how to put humpty dumpty back together again. Any
>> Best regards, Ed
-----BEGIN PGP SIGNED MESSAGE-----
Twisted is very extensive in protocol support, managing smtp, pop3 and
imap4, for example. I was wondering if there is any LMTP server project
out there. It should be fairly simple, since LMTP is very very similar
to usual SMTP. I need to use LMTP for a local project, and I was
wondering if tiwsted could be used to fill this gap.
Jesus Cea Avion _/_/ _/_/_/ _/_/_/
jcea(a)argo.es http://www.argo.es/~jcea/ _/_/ _/_/ _/_/ _/_/ _/_/
jabber / xmpp:firstname.lastname@example.org _/_/ _/_/ _/_/_/_/_/
_/_/ _/_/ _/_/ _/_/ _/_/
"Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/
"My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v126.96.36.199 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----