Questions tagged [twisted.internet]

Twisted Internet: Asynchronous I/O and Events.

Twisted Internet is a collection of compatible event-loops for . It contains the code to dispatch events to interested observers and a portable API so that observers need not care about which event loop is running. Thus, it is possible to use the same code for different loops, from Twisted's basic, yet portable, select-based loop to the loops of various GUI toolkits like GTK+ or Tk.

Project and documentation: http://twistedmatrix.com/documents/current/api/twisted.internet.html

180 questions
4
votes
1 answer

Stopping task.LoopingCall if exception occurs

I'm new to Twisted and after finally figuring out how the deferreds work I'm struggling with the tasks. What I want to achieve is to have a script that sends a REST request in a loop, however if at some point it fails I want to stop the loop. Since…
Michal
  • 6,411
  • 6
  • 32
  • 45
4
votes
1 answer

How to know reactor is running or not in python?

How to know reactor status (running or not) ? I tried this(searched from google): from twisted.internet import reactor if reactor.callWhenRunning(lambda: None) is not None: # do some work It worked, but this seems like weird way. What can be…
Patrick
  • 2,464
  • 3
  • 30
  • 47
3
votes
1 answer

twisted.internet.reactor.spawnProcess raises OSError(13, 'Permission denied')

When I try running a python script via `twisted.internet.reactor.spawnProcess': from twisted.internet import protocol, reactor class ProcessProtocol(protocol.ProcessProtocol): def connectionMade(self): self.transport.closeStdin() …
Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
3
votes
1 answer

Twisted - Python3 TypeError: __init__() missing 1 required positional argument: 'factory'

I'm writing some python software that polls a modbus connection and stores the data in an SQL database. To see if the machine is working as a quick test, I'm making a simple console style "HMI" that you can telnet into. Here is the offending code,…
DonkeyOaty
  • 80
  • 9
3
votes
2 answers

What is the purpose of Twisted's isLeaf attribute?

I found the following example of a Twisted request handler. I'm not clear what the isLeaf attribute is for. Why should I set it on a resource? from twisted.internet import reactor from twisted.web.server import Site from twisted.web.resource import…
John Von Neumann
  • 617
  • 4
  • 15
3
votes
2 answers

How to fix Twisted python Connection to the other side was lost in a non-clean fashion?

I am using buildbot as my CI. Its is built using twisted python. My build worker is getting lost approximately after 10 minutes. My network is fine, but wanted to know why my worker is getting lost. I want to know in what circumstances we will see…
RMK
  • 1,111
  • 4
  • 14
  • 33
3
votes
0 answers

Twisted Python - Two looping calls, one not firing according to given interval

I have a program that is structured something like this: main(): LoopingCall(f1).start(1) LoopingCall(f2).start(10) reactor.run() f1 has some deferreds that deal with some blocking operations. Something like this: f1(): deferred =…
RandomGuyqwert
  • 425
  • 6
  • 18
3
votes
1 answer

Can reactor.connectTCP occur after reactor.run in twisted python?

I wish to add more protocols and factories after reactor runs. I couldn't find documentation which says this is allowed. When I make reactor.run before reactor.connectTCP, the program hangs around buildProtocol in factory. Is it possible to add…
Pippi
  • 2,451
  • 8
  • 39
  • 59
3
votes
1 answer

How to limit the number of simultaneous connections in Twisted

so I have a twisted server I built, and I was wondering what is the best way to limit the number of simultaneous connections? Is having my Factory return None the best way? When I do this, I throw a lot of exceptions like: exceptions.AttributeError:…
3
votes
1 answer

twisted defer make the assignment of class instance variables is invalid

I have a class A with two methods, method_one which uses a defer and method_two , in callback function I set a value to self.value and add it to defer's callback chain. but after that the self.value is still the original value in method_two. in…
Fujiao Liu
  • 2,195
  • 2
  • 24
  • 28
3
votes
1 answer

Receiving broadcast UDP on a specific interface with Twisted Python

I am working on an Ubuntu 14.04 server with multiple interfaces on different subnets. I am trying to write a twisted(13.2.0) application that listens for broadcasts on one interface only, ignoring the other interfaces. I am able to receive…
mknoll
  • 31
  • 2
3
votes
1 answer

Running tests on Twisted code in Python3

I've got a relatively simple SSL server running in Twisted and I'd like to write some unit tests for it. I'm not really sure the best way to do this when using Python 3. All the documentation I've found describes using Twisted Trial which…
Tim Tisdall
  • 9,914
  • 3
  • 52
  • 82
3
votes
0 answers

twisted internet error ConnectionLost while scraping using scrapy framework

I am trying to scrape data from some sites. But after a while the web crawler starts giving twisted internet error ConnectionLost Error. I do not understand the working of twisted. Also,due to this error the web crawlers keep running for ages.…
Bhawna
  • 55
  • 4
3
votes
1 answer

Refactoring for a twisted tcp client from existing blocking code

I have a python program that currently uses a tcp/ip client module I wrote to receive data from a streaming server. The server outputs lines of data. My TCP client class is fairly primitive and I want to refactor to use a twisted…
RoyHB
  • 1,715
  • 1
  • 22
  • 38
3
votes
2 answers

Controlling Twisted based server from a web interface?

I created a server with a custom protocol using Twisted and I have clients that connect to the server on a specific port (say port 1234). I am looking to create a control interface for the server based on a web page of some sort. My research so far…
MikeDW
  • 33
  • 4
1
2
3
11 12