twisted

Python multiprocessing with twisted's reactor

Dear everyone I am working on a xmlrpc server which has to perform certain tasks cyclically. I am using twisted as the core of the xmlrpc service but I am running into a little problem: class cemeteryRPC(xmlrpc.XMLRPC): def __init__(self, dic): xmlrpc.XMLRPC.__init__(self) def xmlrpc_foo(self): return 1 ...

using cookies with twisted.web.client

I'm trying to make a web client application using twisted but having some trouble with cookies. Does anyone have an example I can look at? ...

Good way to write a lightweight client function to be imported Twisted Python

Dear everyone, I have the following server running: class ThasherProtocol(basic.LineReceiver): def lineReceived(self, line): dic = simplejson.loads( line) ret = self.factory.d[ dic['method'] ]( dic['args'] ) self.transport.write( simplejson.dumps( ret) ) self.transport.loseConnection() class Thashe...

Serving static files with Twisted and Django under non-root folders

I am in the process of migrating an application (Sage) from Twisted to Django. Static documentation is currently served under /doc/static, while live (built on-the-fly) documentation are served under /doc/live. Is it possible to use Twisted to serve /doc/static only, leaving Django to serve the rest of /doc/*? ...

Apache vs Twisted

I know Twisted is a framework that allows you to do asynchronous non-blocking i/o but I still do not understand how that is different from what Apache server does. If anyone could explain the need for twisted, I would appreciate it.. ...

Twisted - listen to multiple ports for multiple processes with one reactor

Hi, i need to run multiple instances of my server app each on it's own port. It's not a problem if i start these with os.system or subprocess.Popen, but i'd like to have some process communication with multiprocessing. I'd like to somehow dynamically set up listening to different port from different processes. Just calling reactor.lis...

Twisted(asynch server) vs Django(or any other framework)

I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for re...

Tornado is "a relatively simple, non-blocking web server framework written in Python"--can somewhat explain what that means?

This is probably a stupid question, but what exactly is a "non-blocking web server"? All web servers are technically non-blocking, arent they? otherwise how could they handle simultaneous connections? Apache2 achieves this using a combination of fork() and pthreads. How exactly are Tornado (and Twisted also) different? Do they just set a...

What are the ways to run a server side script forever?

I need to run a server side script like Python "forever" (or as long as possible without loosing state), so they can keep sockets open and asynchronously react to events like data received. For example if I use Twisted for socket communication. How would I manage something like this? Am I confused? or are there are better ways to impl...

Getting Started with Tornado

After installing the necessary packages through apt (python 2.5, simplejson etc) I get an error when I try to run the demos. : Request instance has no attribute 'responseHeaders' /usr/lib/python2.5/site-packages/tornado/web.py, line 404 in flush 402 for k,v in self._generate_headers(): 403 if isinstance(v, list): 404 se...

PyAMF backend choices!

I've been using PyAMF to write a backend for a flex app that will request different groups of hundreds of different images depending on what the client needs. I have been using the "simple_server" WSGI server that PyAMF supplies while developing the flex code. Now I'm ready to write a robust backend that will be able to pull images from ...

Twisted network client with multiprocessing workers?

So, I've got an application that uses Twisted + Stomper as a STOMP client which farms out work to a multiprocessing.Pool of workers. This appears to work ok when I just use a python script to fire this up, which (simplified) looks something like this: # stompclient.py logging.config.fileConfig(config_path) logger = logging.getLogger(_...

Python chat : delete variables to clean memory in functions?

I'm creating a chat daemon in python and twisted framework. And I'm wondering if I have to delete every variable create in my functions to save memory in the long run when multiple users are connected, or are those variable automatically clear?. Here's a strip down version of my code to illustrate my point: class Chat(LineOnlyReceiver...

Chat server with Twisted framework in python can't receive data from flash client

I've develop a chat server using Twisted framework in Python. It works fine with a Telnet client. But when I use my flash client problem appear... (the flash client work find with my old php chat server, I rewrote the server in python to gain performance) The connexion is establish between the flash client and the twisted server: ...

Network programming abstraction, decomposition

I have a problem as follows: Server process 1 Constantly sends updates that occur to a datastore Server process 2 Clients contact the server, which queries the datastore, and returns a result The thing is, the results that process 1 and process 2 are sending back the client are totally different and unrelated. How does one deco...

The latest recommendation for Comet in Python?

I'm going to be implementing Comet in Python (even though I hear good things about erlycomet I'm not thrilled about supporting an Erlang-based web server in addition to everything else in our back end). I've found several possibilities: Diesel Tornado Twisted-comet (I'd give a link but this is my first post and I'm restricted to a sin...

Implementing Comet web services using iPhone to Python (preferably)

I still can't seem to get a "correct" answer to this question. Essentially I want to create a JSON-RPC server with the following functions string subcribe_to_feed( callback ) string get_information( params ) The client is an iPhone application, and the server should be done in Twisted (if possible) The client should be able to do so...

HTTP Download very Big File

I'm working at a web application in Python/Twisted. I want the user to be able to download a very big file (> 100 Mb). I don't want to load all the file in memory (of the server), of course. server side I have this idea: ... request.setHeader('Content-Type', 'text/plain') fp = open(fileName, 'rb') try: r = None while r != '': ...

Standard way of using a single port for multiple sockets?

Hey I am writing an app in Twisted, and as it stands I have 4 servers bound two different ports all communicating with the client via JSON. Is there anyway to bind these 4 servers to the same port and have the interactions remain the same? For instance say the client subscribes to two different feeds, transmitted via a direct socket. R...

Manually giving the twisted (web) network stack a packet to process?

I am running an HTTP server using the twisted framework. Is there any way I can "manually" ask it to process some payload? For example, if I've constructed some Ethernet frame can I ask twisted's reactor to handle it just as if it had just arrived on my network card? ...