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.
Please excuse my bad english, I hope you will understand what I mean,
otherwise feel free to ask.
I'm trying to get error messages from my server. I'm using twisted 2.0.0 with
The server looks like this:
from twisted.spread import pb
from twisted.internet import reactor, threads
#...some other methods, which aren't involved...
def remote_fitness(self, task, taskDescription, serverID):
return threads.deferToThread(self.calc, task, serverID, taskDescription)
def calc(self, task, serverID, taskDescription):
exec('from %s import %s as func' %
#problem: file specified in fileName needn't to be in working directory of
func(task) #calulates something
if __name__ == '__main__':
factory = pb.PBServerFactory(ServerObject())
The client calls, after connection is made.
def1 = root.call_remote("fitness", task, taskDescription, serverID)
def serverErrorCB(self, reason):
If the pythonscript named taskDescription.fileName isn't there
self.serverErrorCB is called - thats ok. But it prints:
reason [Failure instance: Traceback from remote host -- Traceback unavailable]
But I need to know why the call failed. Can anyone please help me to get the
traceback or the exception message that the server prints
(exceptions.ImportError: No module named fitfunc2).
maybe I haven't searched enough, but I don't find anything that halps me to
solve my problem.
I've got a serverapplication. The problem is in the following lines:
application = service.Application("TwistedServerApp")
I don't want to start this with a predetermined port. More like:
twistd -y TwistedServerApp.tac 8800
Is this somehow possible? sys.argv seems impossible to use.
Sorry for my poor english, I'll try to express myself clearly :p
I need to implement something like this:
* it listens on a port 12345 for only one incoming connection if
there is currently no connection
* it can also connect to other host from that port (12345) if there
is currently no connection
Or: Could I write a server which can connect (from the port it's
listening on) to another known server?
Could these be done with twisted?
Any infomatin would be warmly welcome, big thanks!
Im finding that Win32Reactor raises an exception on every iteration of the
main loop if I exceed the limit of 64 WaitForMultipleObjects.
I would prefer to avoid this fairly obvious denial-of-service problem by
limiting the number of concurrent client connections. Is there a standard
solution for this?
Thanks in advance,
When packaging a twisted server implementation with py2exe that uses .tac
(.py) files one ends up with a zip file with all the python dependencies (as
.pyo bytecode), an .exe and the .tac files in the package directory. To me
this seems a bit messy since the distribution is by definition a 'frozen'
exe and any changes to the python modules in the zip will require a rebuild.
With this limitation in mind I initially wrote several patches to twisted
core modules to allow an application to be loaded from a zip file (only .py
modules) which i attached to issue 1092
(http://twistedmatrix.com/bugs/issue1092). Upon further reflection I
realised that this functionality is only really useful in the case of exes
frozen with py2exe and I rewrote my patch to be completely external to the
twisted core (code and test modules which i have attached to this mail).
Would you consider perhaps inclusion of this in the twisted/scripts
directory with a short note in a howto?
P.S. this allows you to specify:
twistd.exe -y <name>
where <name> is the python module name without the .py
constitute "classic cred", which has been deprecated for some time now. "New cred" is available in the modules:
and offers a vastly superior API. The only remaining code in Twisted which uses "classic cred" is the old PB log in method, which is also deprecated (in favor of one based around new cred), and the old application code (twisted.internet.app) which is also deprecated in favor of twisted.application.
It would be nice to remove this code from the next Twisted release. Does anyone have any applications still relying on them which they plan to use with Twisted 2.1? If so, what is preventing you from updating the code to the new, vastly improved APIs?
Jp & Itamar