twisted

How to close file objects when downloading files over FTP using Twisted?

I've got the following code: for f in fileListProtocol.files: if f['filetype'] == '-': filename = os.path.join(directory['filename'], f['filename']) print 'Downloading %s...' % (filename) newFile = open(filename, 'w+') d = ftpClient.retrieveFile(filename, FileConsumer(newFile)) d.addCallback(c...

twistd in Twisted cant be run in window

in command prompt i type >>twistd echobot.tac Traceback (most recent call last): File "C:\Python26\Scripts\twistd.py", line 18, in ? from twisted.scripts.twistd import run ImportError: No module named twisted.scripts.twistd the twistd is at C:\Python26\Scripts\twistd.py #!c:\python26\python.exe # Copyright (c) 2001-2009 Twisted ...

twisted: Failure vs. Error

When should I use a twisted.python.failure.Failure, and when should I use something like twisted.internet.error.ConnectionDone? Or should I do twisted.python.failure.Failure(twisted.internet.error.ConnectionDone), and if so, in what casese should I do that? ...

twisted: catch keyboardinterrupt and shutdown properly

If I have a client connected to a server, and it's chilling in the reactor main loop waiting for events, when I hit CTRL-C, I get a "Connection to the other side was lost in a non-clean fashion: Connection lost." How can I set it up so that I know when a KeyboardInterrupt happens, so that I can do proper clean-up and disconnect cleanly? ...

What are the use cases of Node.js vs Twisted?

Assuming a team of developers are equally comfortable with writing Javascript on the server side as they are with Python & Twisted, when is Node.js going to be more appropriate than Twisted (and vice versa)? ...

twisted: how to communicate elegantly between reactor code and threaded code?

I have a client connected to a server using twisted. The client has a thread which might potentially be doing things in the background. When the reactor is shutting down, I have to: 1) check if the thread is doing things 2) stop it if it is What's an elegant way to do this? The best I can do is some confused thing like: def cleanup(s...

Converting to Twisted Asynchronous Design

Ok I have had a problem expressing my problems with the code I am working on without dumping a ton of code; so here is what it would be synchronously (instead of asking it from the view of it being async). Also for classes when should a variable be accessed through a method argument and when should it be accessed through a instance var...

Twisted vs Google App Engine in serving mobile clients

So far I have been using Twisted to simultaneously serve a lot of mobile clients (Android, iPhone) with their HTTP requests exchanging JSON messages. For my next project I'd like to try out Google App Engine, but I'm wondering if it is capable of doing the same or if I should rather go with a custom built solution again. ...

Making a python program wait until Twisted deferred returns a value

I have a program that fetches info from other pages and parses them using BeautifulSoup and Twisted's getPage. Later on in the program I print info that the deferred process creates. Currently my program tries to print it before the differed returns the info. How can I make it wait? def twisAmaz(contents): #This parses the page (amazon ...

How do I run django test case?

I am using twisted to pass in a variable into my django environment so I have to run the twisted server. Hence when I am testing my django app I really need to run the twisted code it runs something like this: def wsgi_resource(): pool = threadpool.ThreadPool() pool.start() # Allow Ctrl-C to get you out cleanly: reactor...

Twisted logging

I have 3 processes running under my twisted reactor: Orbited, WSGI (running django), and Twisted itself. I am currently using log.startLogging(sys.stdout) When all the log are directed to the same place, there is too much flooding. One line of my log from WSGI is like this: 2010-08-16 02:21:12-0500 [-] 127.0.0.1 - - [16/Aug/2010:0...

twisted + gtk: should I run GUI things in threads, or in the reactor thread?

From what I understand about twisted, nothing running in the reactor thread should block. All blocking activities should be delegated to other threads, to fire callbacks back into the reactor thread when they're done. So does this apply to gtk things as well? For example, I want to display a "connection failed" message if the connection...

Twisted: deferred that fires repeatedly?

Deferreds are a great way to do asynchronous processing in Twisted. However, they, like the name implies, are for deferred computations, which only run and terminate once, firing the callbacks once. What if I have a repeated computation, like a button being clicked? Is there any Deferred-like object that can fire repeatedly, calling all ...

Are twisted RPCs guaranteed to arrive in order?

I'm using twisted to implement a client and a server. I've set up RPC between the client and the server. So on the client I do protocol.REQUEST_UPDATE_STATS(stats), which translates into sending a message with transport.write on the client transport that is some encoded version of ["update_stats", stats]. When the server receives this me...

Which key-value store has decent twisted API (nonblocking) ?

I need a reliable K-V storage to be run in network. Main requirements: Network connectivity has nonblocking twisted API be reliable, production ready. No data loss write performance is more important than read performance support for distributed operation and failover would be great (So I just specify list of nodes) java/ruby/erlang AP...

Pluggable twisted apps?

Is there such a thing as pluggable twisted apps some one can add to a twisted project? One example of this could be a web logging. That's a web app where you can access the results of your logging process. ...

Twisted and starpy error (python)

Hi I'm using this: from twisted.web.client import getPage df = getPage(url) # there is some url I'm getting the following error. Please can anyone guide me on this ERROR:twsited:Unhandled error in Deferred: ERROR:twsited:Unhandled Error Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/starpy/manager....

Indentation Error python

I'm using twisted API and was going through this example. I inserted one print statement print "in getdummydata" with correct indentation. code is as below: from twisted.internet import reactor, defer def getDummyData(x): """ This function is a dummy which simulates a delayed result and returns a Deferred which will fire wi...

FTP Detect if active or passive modes are enabled.

Specifically for Twisted, I would like to be able to determine whether the server I am connected to supports active or passive mode. http://twistedmatrix.com/documents/10.1.0/api/twisted.protocols.ftp.FTPClient.html If somebody could explain or give example in FTP protocol how you can determine whether the server supports active or pas...

Twisted Server Receiving TCP call (unit created from web), then periodically check status of units on different delay?

I have 100 units having TCP socket implementation and answering to commands from a server, I would like to implement this server listening on other end from web framework (registering or deleting a unit, then create a tcp client to this twisted server) then the server creates a task.LoopingCall with specific delay per unit to run multipl...