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
1
vote
0 answers

Sharing data between binance twisted.internet websocket and asyncio thread

I am using the following libraries: from binance.websockets import BinanceSocketManager from twisted.internet import reactor To create a websocket to fetch data from an API (Binance API) and print the price of bitcoin in 1s intervals: conn_key…
1
vote
1 answer

Twisted Producer was never unregistered

I am writing a custom SSL proxy with Twisted. I keep running in to an issue that happens every so often and I cant figure out what the problem is. When I try to connect the client transport to the server's transport through the registerProducer…
GeneralZero
  • 290
  • 1
  • 3
  • 15
1
vote
1 answer

Twisted unittest "Reactor Unclean" when using TimeoutMixin

I'm implementing a protocol which may be instantiated with different timeouts, so I use TimeoutMixin. The idea can be represented with this dummy class: my_protocol.py from twisted.protocols import basic, policies from twisted.internet import…
Simon
  • 33
  • 7
1
vote
0 answers

How to generate events on serial control lines in twisted

Is it possible to get an 'event' callback within Twisted when DCD or CTS lines change state? Currently my app uses twisted.internet.serialport.SerialPort and a LoopingCall() to check for changes in these lines once a second. This works, but isn't…
Dave Lawrence
  • 1,281
  • 12
  • 17
1
vote
0 answers

Celery worker hang when running with twisted

Below code snippet is the celery setup I have, Here I am running a twisted reactor in each child celery worker process. import os from threading import Thread from celery import Celery from twisted.internet import threads, reactor from celery import…
Prashant Gaur
  • 9,540
  • 10
  • 49
  • 71
1
vote
1 answer

twisted python TCP4ServerEndpoint

error no module TCP4.... found. both on windows and ubuntu 10.04.. do i need to install anything new. I tried to copy endpoints.py to a directory. but not worked
Dickson Xavier
  • 99
  • 1
  • 1
  • 11
1
vote
1 answer

Running long blocking calculations in parallel in twisted

I am trying to learn twisted framework. But, I am not able to get a handle of it. Say, I have this function. def long_blocking_call(arg1, arg2): # do something time.sleep(5) # simulate blocking call return result results = [] for k,…
frazman
  • 32,081
  • 75
  • 184
  • 269
1
vote
2 answers

Getting ReactorNotRestartable error when though I am checking if the reactor is already running

Code: def hook(ui, repo, hooktype, node=None, source=None, **kwargs): from buildbot.clients import sendchange from twisted.internet import defer, reactor for master in masters: s = sendchange.Sender(master, auth=(username,…
Javed
  • 5,904
  • 4
  • 46
  • 71
1
vote
1 answer

Scrapy throuws Exception "raise _DefGen_Return(val) twisted.internet.defer._DefGen_Return: "

When I run the code locally (windows 10) everything works fine. Have checked other answers here and other resources, but failed to figure out any solution. After deploying to ScrapingHub Im getting this error message: [scrapy.core.scraper] Spider…
Billy Jhon
  • 1,035
  • 15
  • 30
1
vote
0 answers

Twisted test: Reactor was unclean

I'm working on implementing a stream protocol and currently trying to setup unit tests before using new implementation further up the application code. While creating a simple version of the test, I came across the issue of leaving reactor…
IvanR
  • 533
  • 4
  • 23
1
vote
1 answer

Unhandled error in Deferred in twisted deferToThread

I have client/server code example from twisted. Now, my requirement is that when a call is made to server from the client - the server defers the call to a thread, who actually replies back to the client and the server can do something else. In…
yguw
  • 856
  • 6
  • 12
  • 32
1
vote
1 answer

Twisted: catching DNSLookupError upon internet connection drop

I have a simple twisted script which sends GET requests to some API endpoint. It works fine, except that when my internet connection drops it pollutes the log with a bunch of Unhandled error in Deferred: messages. The minimal example looks like…
Yuri Lifanov
  • 347
  • 1
  • 2
  • 11
1
vote
1 answer

Starting and stopping Twisted connections

I'm writing application that uses python Twisted API (namely WebSocketClientProtocol, WebSocketClientFactory, ReconnectiongClientFactory. I want to wrap client factory into reader with following interface class Reader: def start(self): …
1
vote
2 answers

How to set subprotocol list for Client (Twisted)

Hey everyone, I have created a Client and a Server to communicate over websockets. The Twisted library is used for the websockets, and eventually I will be sending GraphQL strings from Client to Server. However, I am getting an error that…
Brian
  • 421
  • 3
  • 20
1
vote
1 answer

Checking if a connection was closed with Twisted

I'm using Twisted to write a proxy server and I'm having issues with checking if a connection to the server was closed. As it is now, I have client <-> proxy <-> server Testing with telnet, the proxy successfully passes messages from the client to…