twisted

persistant TCP connection in Django

Hi, I have a Django application which sometimes needs to send some data through TCP and I want this connection to be persistant. The way I wanted to do it was to create a simple Twisted TCP server (I'm the one who will be waiting for the initial connection) and somehow call it from a Django view whenever I would be needing it. How s...

Fastest way to produce UDP packets

We're building a test harness to push binary messages out on a UDP multicast. The prototype is using the Twisted reactor loop to push out messages, which is achieving just about the level of traffic we require - about 120000 messages per second. We have a 16 cores on our test machine, and obviously I'd like to spread this over those co...

Is Python good for writing standard, compatible and complete SOAP web services?

I have used few python soap libraries (SOAPpy, soaplib and Twisted wrapper around SOAPpy) to write my soap web service. When I used python clients (SOAPpy.SOAPProxy and SUDS), I was able to communicate with my web service (returning simple and complex type objects). But, when I tried with C# ASP.net, I got many issues. I came over retu...

twisted web getPage, 2 clients in 2 classes, manage events between the two

Hi All, i'm trying to create a bridge program in twisted.web that receives data from a web server and sends it to another server, thus i'm using 2 getPage applications that i have wrapped in a class for convenience, the class contains all the callbacks and the client "routine".. 1)auth 2)receive data 3)send data, all this is done in a c...

IRCBot won't join a channel

Hi, I'm trying to build a very simple irc bot for now but it seems like my bot won't join the channel. Can someone point out what's wrong with the following code: from twisted.internet import reactor, protocol from twisted.words.protocols import irc class IRCProtocol(irc.IRCClient): nickname = "botnick" def connectionMade(self...

python twisted tutorial/question

Hi guys... Got a simple question regarding twisted. I can create a trivial basic test with a web server like apache, where http://foo.com/index.php instantiates the index.php for the "foo" site/app... I'm trying to figure out how the heck I can create a twisted server, where I run different backend functions based on the input! I kno...

question comparing multiprocessing vs twisted

Hi. Got a situation where I'm going to be parsing websites. each site has to have it's own "parser" and possibly it's own way of dealing with cookies/etc.. I'm trying to get in my head which would be a better choice. Choice I: I can create a multiprocessing function, where the (masterspawn) app gets an input url, and in turn it spans...

Twisted.Web and AJAX

I've implemented a toy web service in Twisted.Web: from twisted.web import server, resource, http class RootResource(resource.Resource): def __init__(self): resource.Resource.__init__(self) self.putChild('test', TestHandler()) class TestHandler(resource.Resource): isLeaf = True def __init__(self): res...

Use deferred to make an infinite call loop

Can we use deferred (http://twistedmatrix.com/documents/current/core/howto/defer.html) to make an infinite call loop in which a function adds itself to a deferred chain? I tried to do this, but it doesn't work: d = deferred.Deferred() first = True def loopPrinting(dump): ch = chr(random.randint(97, 122)) print ch global d, first ...

getting following error while scanning constantly database table using reactor in twisted

Hi, I am getting following error,after few few hours of successful run. Traceback (most recent call last): File "/usr/lib/python2.6/threading.py", line 484, in run self.__target(*self.__args, **self.__kwargs) File "/usr/lib/python2.6/dist-packages/twisted/python/threadpool.py", line 210, in _worker result = context.call(...

Twisted Web Proxy

Found the Answer. In Firefox set the proxy ip address not to localhost or 127.0.0.1 but instead set it as the 192.168.x.x or the 10.10.x.x to find this open cmd and type ipconfig /all (windows) or on linux ifconfig and find out what your ip address is. I have been running this code (from: http://blog.somethingaboutcode.com/?p=155 ): ...

Simple Twisted server won't write with Timer

I'm just learning Python and Twisted and I can't figure out for the life of me why this simple server won't work. The self.transport.write doesn't work when called from a timer. I get no error at all. Any help appreciated. Thank you very much! from twisted.internet.protocol import Factory, Protocol from twisted.internet import reactor f...

Simple protocols (like twisted.pb) vs messaging (AMQP/JMS) vs web services (REST/SOAP)

Hi, I'm currently using twisted's perspective broker on python and I have considered in the past switching to something like RabbitMQ but I'm not sure it could just replace pb - I feel like I might be comparing apples to oranges here. I've been reading a lot about REST lately and the inevitable debate with SOAP, which led me to read abou...

Twisted: degrade gracefully performance in case reactor is overloaded?

Is it somehow possible to "detect" that the reactor is overloaded and start dropping connections, or refuse new connections? How can we avoid the reactor being completely overloaded and not being able to catch up? ...

Is twisted.internet.reactor global?

For example, if one application does from twisted.internet import reactor, and another application does the same, are those reactors the same? I am asking because Deluge, an application that uses twisted, looks like it uses the reactor to connect their UI (gtk) to the rest of the application being driven by twisted (I am trying to under...

How to detect HTTP Request in python + twisted?

I am learning network programming using twisted 10 in python. In below code is there any way to detect HTTP Request when data recieved? also retrieve Domain name, Sub Domain, Port values from this? Discard it if its not http data? from twisted.internet import stdio, reactor, protocol from twisted.protocols import basic import re c...

what is fastest as a django production server : twisted.web2 vs. apache mod_wsgi

i want to deploy my django project, what is best (on performance) of these 2 deployment methodologies: Django-On-Twisted apache mod_wsgi i knew that mod_wsgi was recommended by django developers but i feel twisted is more efficient when running multiple django instance. ...

What is twisted's equivalent of tornado's IOLoop.add_callback?

I'm trying to adapt some tornado code to work with twisted. Tornado's IOLoop has a function (add_callback) that will essentially call the function back in the next iteration of the loop. As far as I can tell, twisted doesn't have a direct translation of this. Is there any way to simulate this in twisted? ...

Designing a interface to a websites api

Ok I am programing a way to interface with Grooveshark (http://grooveshark.com). Right now I have a class Grooveshark and several methods, one gets a session with the server, another gets a token that is based on the session and another is used to construct api calls to the server (and other methods use that). Right now I use it like so....

Python Object Oriented Design with Twisted defereds

My question is about how to design code that works well with object oriented design and asynchronous deferreds (instead of blocking code) Ok two ways I am thinking about designing the class (are any of these good designs or am I forgetting something) First Way class Grooveshark(object): def get_session(self): d = # implementation ...