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?
Does anyone have some example code for building a reconnecting PB client?
This is what I have now:
from twisted.spread import pb
from twisted.internet import reactor
from twisted.python import util
events = pb.PBClientFactory()
reactor.connectTCP("localhost", 8789, events)
queue = events.getRootObject()
I've been googling if there is any 'ICMP ping' support in Twisted. I've
encounter ancient replies:
I wonder if today is any ICMP support. I've tried to search the source
tree, and doesn't seem.
My actual needs is creating a DeferredList with "ping-testers" for different
IPs, just to check if there up or not.
I know I can end up using twisted.internet.utils.getProcessOutput and calling
ping, as I would normally do from command line. For other newbies as me in
the same situation please read:
http://twistedmatrix.com/users/moshez/talk.html and search
for 'getProcessOutput' ;-)
 my search was:
$ grep -C3 -ir icmp *
internet/protocol.py: """Abstract protocol for datagram-oriented
transports, e.g. IP, ICMP, ARP, UDP."""
internet/protocol.py- transport = None
internet/protocol.py- numPorts = 0
internet/protocol.py- def connectionRefused(self):
internet/protocol.py- """Called due to error from write in connected
internet/protocol.py: Note this is a result of ICMP message generated
Nicolás D. César <ncesar(a)lunix.com.ar>
Lunix S.R.L. -[ http://www.lunix.com.ar ]-
GnuPG Public Key: gpg --keyserver wwwkeys.pgp.net --recv-key 0x3606F3E6
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'm using the qtreactor in a GPL-but-unreleased PyQt 4.1 application of
my own, and have not found any problems whatsoever with the integration
of the Qt Twisted event loops. It's really a pretty slick combination.
As an example and a contribution, I offer the following (GPL'd) module:
http://deadbeefbabe.org/paste/1996 (syntax-highlighted version),
http://foss.eepatents.com/misc/qt-twisted-dialog.py (source). It allows
you to construct a non-blocking modal dialog, immediately obtaining a
deferred to the user's eventual input.
As an aside, I would be interested in people's viewpoints about whether
the Qt reactor is suitable for Twisted's MIT-style license, given that
it doesn't actually import any Qt code itself. It leaves that step up to
the user with the installation of a reactor into the Qt application
object. As every Qt user probably knows, the Qt library itself is
dual-licensed under either the GPL or Trolltech's proprietary license.
Best regards, Ed
From the msdn:
Nonblocking mode is enabled. In this mode, ReadFile, WriteFile, and
ConnectNamedPipe always return immediately. Note that nonblocking mode
is supported for compatibility with Microsoft® LAN Manager version 2.0
and should not be used to achieve asynchronous input and output (I/O)
with named pipes.
I really can't believe that win32 support for asynchronous I/O works
with named pipes but not with anonymous pipes...
By the way, instead of using a polling, why not to use a separate thread
that puts data into a DeferredQueue?
"""Anonymous pipes are implemented using a named pipe with a unique
name. Therefore, you can often pass a handle to an anonymous pipe to a
function that requires a handle to a named pipe.
"""A child process can inherit [...]
* Open handles returned by the CreateFile function. This includes
handles to files, console input buffers, console screen buffers, named
pipes, serial communication devices, and mailslots.
* Open handles to process, thread, mutex, event, semaphore, named-pipe,
anonymous-pipe, and file-mapping objects. These are returned by the
CreateProcess, CreateThread, CreateMutex, CreateEvent, CreateSemaphore,
CreateNamedPipe, CreatePipe, and CreateFileMapping functions, respectively.
So, why not to create a named pipe with an unique name, know to both the
parent and the child process, as an example using an enviroment variable?
I think that using named pipes can simplify the _dumbwin32proc.
Moreover polling a named pipe is not an efficient operation
(reading the author of "Windows System Programming").
Lastly, the parent process, after creating a named pipe instance, can
wait for a client connection using ConnectNamedPipe.
Regards Manlio Perillo
I've readied my app for use with twistd, the daemonizing works, but a
tap file is not saved upon exit (kill 'cat twisted.pid'). How can I
enable the save state option? BTW I'm not using the -o option with twistd ;)
Second ... is it possible to disable the twisted logging if you use
twistd to start the app? Or is it possible to set a log level so that
only warnings and errors are shown and my log is not flooded with
(TCPServer) connection messages.
- Remi -
So, I would like to remove _wait() from Trial and make it work like a
regular Twisted application. I've had all this stuff on my brain, and
have decided to dump it here for feedback. Here's how the plan looks
at the moment:
1. Deprecate the use of reactor-spinning things within tests. (Twisted 2.5)
We've already done a great deal of work on this. spinWhile, spinUntil
and util.wait have alll been deprecated and removed.
#2090 (ready for review) actually issues deprecation warnings when the
reactor is iterated, crashed or stopped within a test.
Unfortunately, some of Trial's cleanup code spins the reactor (see
t.trial.util._Janitor.do_cleanPending). This has to go.
2. Tighten test cleanup errors. (Twisted 2.5)
#2091 (ready for review) fulfils a long-standing promise. The "reactor
unclean" warnings have been turned into errors. It doesn't help us
remove _wait, but
To remove _wait, we'll also have to remove the two calls to
reactor.iterate() from _Janitor (see #2092). That means that many
tests that *thought* they were cleaning up the reactor properly will
find out that they weren't. We can reduce the number of errors by
simulating reactor.iterate() using callLater. However, experiments
show that even with this bandaid, there will still be new errors in
the Twisted suite.
That means we will have to either:
a) surprise our users with new errors in their tests
b) find some way to introduce this gradually.
Obviously everyone would prefer b). I've filed #2124 explaining how
that might work.
3. Introduce asynchronous APIs to Trial (Twisted 2.6)
Currently TestCase.run() is a blocking call. I wish it could remain a
blocking call, but it can't.
The branch for #1781 makes a SyncTestCase and an AsyncTestCase. run()
works in SyncTestCase and doesn't work in AsyncTestCase. For
AsyncTestCase, one uses runDeferred().
Although the branch for #1781 will need to be abandoned, these new
classes should be brought in for Twisted 2.6 (without breaking run()).
Naturally, this affects many, many tests in Trial.
We might even add runDeferred to TestSuite at this point.
4. Deprecate TestSuite.run and TestCase.run. (Twisted 2.6)
Neither of these will work without wait and they are both public
APIs. Also remove the calls to iterate() from _Janitor at this point.
5. Actually remove _wait. (Twisted 2.7)
Add runDeferred() to TestSuite, make run() raise NotImplementedErrors
for TestCase and TestSuite. Alter TrialSuite to start and stop the
I can't find a theory to explain why this change will break unexpected
tests in the Twisted suite. However, it will certainly happen. That
means that some tests in user code will probably break as well. I
don't know how we could make this any smoother.
- What should I do with the ticket #1781?
- What should I do with the branch for #1781?
- What more can we do to reduce the number of tests that will break
when _wait is removed?
thanks for getting this far :),
 Incidentally, all of this would be superfluous if reactors were restartable.
 Well, almost everyone
 ... or restartable reactors.