twisted

Twisted: ReconnectingClientFactory connection to different servers

半城伤御伤魂 提交于 2019-12-01 06:51:51
I have a twisted ReconnectingClientFactory and i can successfully connect to given ip and port couple with this factory. And it works well. reactor.connectTCP(ip, port, myHandsomeReconnectingClientFactory) In this situation, when the server is gone, myHandsomeReconnectingClientFactory tries to connect same ip and port (as expected). My goal is, when the server which serves on given ip and port couple is gone, connecting to a backup server (which have different ip and port). Any ideas/comments on how to achieve this goal will be appreciated. Id try something like: class

Proper way to close all files after subprocess Popen and communicate

心已入冬 提交于 2019-12-01 05:53:07
问题 We are having some problems with the dreaded "too many open files" on our Ubuntu Linux machine rrunning a python Twisted application. In many places in our program, we are using subprocess Popen, something like this: Popen('ifconfig ' + iface, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) output = process.stdout.read() while in other places we use subprocess communicate: process = subprocess.Popen(['/usr/bin/env', 'python', self._get_script_path(script_name)], stdin

Twisted application without twistd

☆樱花仙子☆ 提交于 2019-12-01 05:43:14
I've wrote a nice app for myself using the Twisted framework. I launch it using a command like: twistd -y myapp.py --pidfile=/var/run/myapp.pid --logfile=/var/run/myapp.log It works great =) To launch my app I wrote a script with this command because I'm lazy^^ But since I launch my app with the same twistd option, and I tink the script shell solution is ugly, how I can do the same but inside my app? I'd like to launch my app by just doing ./myapp and without a shell work around. I've tried to search about it in twisted documentation and by reading twisted source but I don't understand it

How to use Twisted to get an IRC channel's user list

坚强是说给别人听的谎言 提交于 2019-12-01 05:35:43
I'm trying to get channel's user list using {{self.say(channel, "WHO",100)}} . How can I get the response? Which method I should override? Here are some additional methods which should help you get further along. You handle a given reply RPL_NAME by defining a method irc_RPL_NAME . So for RPL_WHOREPLY you define irc_WHOREPLY : def who(self, channel): "List the users in 'channel', usage: client.who('#testroom')" self.sendLine('WHO %s' % channel) def irc_RPL_WHOREPLY(self, *nargs): "Receive WHO reply from server" print 'WHO:', nargs def irc_RPL_ENDOFWHO(self, *nargs): "Called when WHO output is

How to send Autobahn/Twisted WAMP message from outside of protocol?

浪尽此生 提交于 2019-12-01 05:22:21
I am following the basic wamp pubsub examples in the github code : This example publishes messages from within the class: class Component(ApplicationSession): """ An application component that publishes an event every second. """ def __init__(self, realm = "realm1"): ApplicationSession.__init__(self) self._realm = realm def onConnect(self): self.join(self._realm) @inlineCallbacks def onJoin(self, details): counter = 0 while True: self.publish('com.myapp.topic1', counter) counter += 1 yield sleep(1) I want to create a reference so that I can publish messages over this connection from elsewhere

Python Jabber/XMPP client library for Twisted [closed]

只谈情不闲聊 提交于 2019-12-01 04:42:51
I am looking for a Python library for writing Jabber/XMPP clients using the Twisted framework. Wokkel is your best bet. It's an enhancement on the core Twisted Words functionality built into Twisted. It has several major users, include the guys behind Stanziq/Strophe . Twisted Words 来源: https://stackoverflow.com/questions/2248587/python-jabber-xmpp-client-library-for-twisted

twisted - interrupt callback via KeyboardInterrupt

让人想犯罪 __ 提交于 2019-12-01 04:09:50
问题 I'm currently repeating a task in a for loop inside a callback using Twisted, but would like the reactor to break the loop in the callback (one) if the user issues a KeyboardInterrupt via Ctrl-C. From what I have tested, the reactor only stops or processes interrupts at the end of the callback. Is there any way of sending a KeyboardInterrupt to the callback or the error handler in the middle of the callback run? Cheers, Chris #!/usr/bin/env python from twisted.internet import reactor, defer

Maximum number of connections per host with twisted.web.client.Agent

假装没事ソ 提交于 2019-12-01 03:55:45
问题 I have the following code which creates an HTTPConnectionPool using TwistedMatrix Python framework, and an Agent for HTTP requests: self.pool = HTTPConnectionPool(reactor, persistent=True) self.pool.retryAutomatically = False self.pool.maxPersistentPerHost = 1 self.agent = Agent(reactor, pool=self.pool) then I create requests to connect to a local server: d = self.agent.request( "GET", url, Headers({"Host": ["localhost:8333"]}), None) The problem is: the local server sometimes behaves

Twisted application without twistd

落爺英雄遲暮 提交于 2019-12-01 03:44:07
问题 I've wrote a nice app for myself using the Twisted framework. I launch it using a command like: twistd -y myapp.py --pidfile=/var/run/myapp.pid --logfile=/var/run/myapp.log It works great =) To launch my app I wrote a script with this command because I'm lazy^^ But since I launch my app with the same twistd option, and I tink the script shell solution is ugly, how I can do the same but inside my app? I'd like to launch my app by just doing ./myapp and without a shell work around. I've tried

'NoneType' object has no attribute '_app_data' in scrapy\\twisted\\openssl

旧时模样 提交于 2019-12-01 03:14:22
During the scraping process using scrapy one error appears in my logs from time to time. It doesnt seem to be anywhere in my code, and looks like it something inside twisted\openssl. Any ideas what caused this and how to get rid of it? Stacktrace here: [Launcher,27487/stderr] Error during info_callback Traceback (most recent call last): File "/opt/webapps/link_crawler/lib/python2.7/site-packages/twisted/protocols/tls.py", line 415, in dataReceived self._write(bytes) File "/opt/webapps/link_crawler/lib/python2.7/site-packages/twisted/protocols/tls.py", line 554, in _write sent = self.