Questions tagged [twisted]

Twisted is an event-driven networking engine, written in Python and implementing many different protocols.

Twisted is a multi-protocol, event-driven, liberally-licensed open-source networking engine written in Python. It is useful for implementing both clients and servers, and scales up to large websites and down to embedded devices. Twisted makes it easy to implement custom network applications.

3465 questions
26
votes
3 answers

What is the point/purpose of Ruby EventMachine, Python Twisted, or JavaScript Node.js?

I don't understand what problem these frameworks solve. Are they replacements for a HTTP server like Apache HTTPD, Tomcat, Mongrel, etc? Or are they more? Why might I use them... some real world examples? I've seen endless examples of chat rooms…
CCw
  • 271
  • 3
  • 3
24
votes
2 answers

Running a function periodically in twisted protocol

I am looking for a way to periodically send some data over all clients connected to a TCP port. I am looking at twisted python and I am aware of reactor.callLater. But how do I use it to send some data to all connected clients periodically ? The…
Amit
  • 733
  • 1
  • 5
  • 10
24
votes
2 answers

How to make Twisted use Python logging?

I've got a project where I'm using Twisted for my web server. When exceptions occur (such as network errors), it's printing to the console. I've already got logging through Python's built-in log module - is there any way to tell the reactor to use…
Dave
  • 2,029
  • 2
  • 21
  • 30
23
votes
1 answer

Tornado/Twisted - Celery - Gevent Comparison

I'm having a bit of trouble understanding the differences between these three frameworks: Tornado/Twisted Celery Gevent These three frameworks can be used to run code at the same time but do this in different way using a different amount of…
arnoutaertgeerts
  • 2,232
  • 5
  • 29
  • 44
23
votes
7 answers

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…
John R
  • 231
  • 1
  • 2
  • 4
22
votes
5 answers

Basic networking with Pygame

I need to do some basic networking for a Pygame project. Basically, it's a 2D single player or cooperative game. The networking only needs to support two players, with one as a host. The only information that needs to be sent is the positions of…
Lightbreeze
  • 4,624
  • 3
  • 15
  • 10
22
votes
2 answers

Stop twisted reactor on a condition

Is there a way to stop the twisted reactor when a certain condition is reached. For example, if a variable is set to certain value, then the reactor should stop?
gmemon
  • 2,573
  • 5
  • 32
  • 37
21
votes
2 answers

How do I catch errors with scrapy so I can do something when I get User Timeout error?

ERROR: Error downloading : User timeout caused connection failure. I get this issue every now and then when using my scraper. Is there a way I can catch this issue and run a function when it happens? I can't find out how to do it…
Ryan Weinstein
  • 7,015
  • 4
  • 17
  • 23
21
votes
2 answers

Installing Twisted through pip broken on one server

I am setting up a virtualenv on a new server, and when I used pip on our requirements file, it kept dying on Twisted. I commented the Twisted line out, and everything else installed fine. At the command line, this is the output I see when I try to…
Rjak
  • 2,097
  • 4
  • 19
  • 24
20
votes
1 answer

Twisted: Making code non-blocking

I'm a bit puzzled about how to write asynchronous code in python/twisted. Suppose (for arguments sake) I am exposing a function to the world that will take a number and return True/False if it is prime/non-prime, so it looks vaguely like this: def…
acrophobia
  • 924
  • 7
  • 22
20
votes
3 answers

How do you *properly* query Redis from Tornado?

I'm curious what the recommended method of querying Redis (or any DB for that matter) is from Tornado. I've seen some examples like https://gist.github.com/357306 but they all appear to be using blocking calls to redis. My understanding is that to…
jarcoal
  • 1,445
  • 2
  • 16
  • 19
20
votes
3 answers

Redirecting before POST upload has been completed

I have form with file upload. The files to be uploaded actually are pictures and videos, so they can be quite big. I have logic which based on headers and first 1KB can determine if the rest will be processed or immediately rejected. In the later…
vartec
  • 131,205
  • 36
  • 218
  • 244
20
votes
6 answers

How do you you run a Twisted application via Python (instead of via Twisted)?

I am working my way through learning Twisted, and have stumbled across something I'm not sure I'm terribly fond of - the "Twisted Command Prompt". I am fiddling around with Twisted on my Windows machine, and tried running the "Chat" example: from…
Mike Trpcic
  • 25,305
  • 8
  • 78
  • 114
20
votes
4 answers

Python - Twisted and Unit Tests

I'm writing unit tests for a portion of an application that runs as an HTTP server. The approach I have been trying to take is to import the module that contains the HTTP server, start it. Then, the unit tests will use urllib2 to connect, send…
Dave
  • 2,029
  • 2
  • 21
  • 30
20
votes
2 answers

Scrapy crawl from script always blocks script execution after scraping

I am following this guide http://doc.scrapy.org/en/0.16/topics/practices.html#run-scrapy-from-a-script to run scrapy from my script. Here is part of my script: crawler = Crawler(Settings(settings)) crawler.configure() spider =…
Eugene Nagorny
  • 1,626
  • 3
  • 18
  • 32