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).
(I am new to twisted, so please excuse me if my question is not
I am using the python module kinterbasdb  for connecting to a
Firebird DB, and I wonder if it's possible, using twisted, to pass this
connection through a ssh tunnel, which should be created on the fly by
twisted (without running a /usr/bin/ssh commandline)...
best regards and thanks in advance,
in an instance of protocol.basic.lineOnlyReceiver i i read in a file in
a string and try to send this string to another instance of
protocol.basic.lineOnlyReceiver trough the normal
self.transport.write(theString + "\r\n")
when doing this i get the error message:
IK_IC_TSS 16:13:53:03 connectionLost() for the instance IK_IC_TSS due
to reason: [Failure instance: Traceback (failure with no frames):
twisted.internet.error.ConnectionLost: Connection to the other side was
lost in a non-clean fashion.
The file is a normal text file of about 200KB.
I googled for similar types of errors, but could not find smth.
Is there an explicit string size limit or is it just the fact the the
lineOnlyReceiver is not built for that kind of data transfer?
In response to the announcement of the Twisted Asynchronous Database Api
(tada), <http://www.darkarts.co.za/projects/tada/, I thought I should
mention something I wrote.
[Unfortunately, tada does not use threads correctly so it's likely to
break. The author knows this and has added a warning to the module for now.]
A while back, I started messing around with making a standard, blocking
db-api module appear non-blocking but with a deferred API. I called it
laxdb and it's in my sandbox.
laxdb is quite literally an async db-api interface and not a
t.enterprise.adbapi style interface. In particular, it provides exactly
the same API (but deferred) and it doesn't take over transaction
management. It also doesn't wrongly call a cursor, "Transaction" ;-).
I recently went back to laxdb and finished it off, also adding a
connection pool implementation.
Now, I haven't used laxdb in a real project and there are no unit tests
but I think it's reasonably complete. It should work with any dbapi
module that has threadsafety level 1 or higher, just like adbapi.
If there's interest in this way of accessing a database then I would be
happy to write tests etc, move it into Twisted and maintain it.
/ \__ 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.
Is there any rpm packages available for
twisted , if any get me the link for the source
package. If anyone had tried twisted in Redhat linux
kindly guide me out for the installation.
Yahoo! India Matrimony: Find your partner online. Go to http://yahoo.shaadi.com
On 31 Aug 2005 06:03:00 -0700, n00m <n00m(a)narod.ru> wrote:
>import socket, thread
>host, port = '192.168.0.3', 1434
>s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>cn, addr = s1.accept()
> while 1:
> data = cn.recv(4096)
> if not data: return
> print 'VB_SCRIPT:' + data + '\n\n'
> while 1:
> data = s2.recv(4096)
> if not data: return
> print 'SQL_SERVER:' + data + '\n\n'
This is about the same as:
mktap portforward --port 1434 --host 192.168.0.3 --dest_port 1433
twistd -f portforward.tap
You'll find the code behind these two commands here:
And of course, the main Twisted site is <http://twistedmatrix.com/>.
Some differences between portforward.tap and your code include:
portforward.tap will accept multiple connections, rather than just one. portforward.tap won't print out all the bytes it receives (I assume this is just for debugging purposes anyway - if not, a simple modification will cause it to do this). portforward.tap won't non-deterministically drop traffic, since Twisted checks the return value of send() and properly re-transmits anything which has not actually been sent.
Hope this helps,