twisted

What is the best way to control Twisted's reactor so that it is nonblocking?

柔情痞子 提交于 2019-12-13 13:04:37
问题 Instead of running reactor.run(), I'd like to call something else (I dunno, like reactor.runOnce() or something) occasionally while maintaining my own main loop. Is there a best-practice for this with twisted? 回答1: Yes. The best practice is that this is a bad idea, and that you never really need to do it. It doesn't work with all reactors, and you certainly can't have two different libraries which want to do this. Why do you need to maintain your own main loop? Chances are, it's something

What's the difference between a twistd plugin and a twistd service?

六眼飞鱼酱① 提交于 2019-12-13 13:02:36
问题 Apparently you can create services that are run with Twisted's twistd in two different ways. On the one hand you can create services using the Twisted Application Infrastructure and in the other you can create a service using the Twisted Plugin System. It seems like besides some differences in how you start the the app on the command line, and the means by which you write the actual service, they are two ways to accomplish the same thing? 回答1: Looks like I found the answer: http:/

twisted python server port already in use

人盡茶涼 提交于 2019-12-13 08:52:17
问题 (using a mac by the way) I'm following this tutorial for building a twisted python socket server and everything is going great. the one issue I'm facing is I don't know how to turn off the server. Basically I changed some code in my python script and I'd like to restart the server but I don't know how. I tried killing all python processes from my activity monitor, but when I try to run the server again, I get an error that the server can't listen on port 80. here's the script: from twisted

Python Twisted Stopping The Reactor With Multiple Clients

拥有回忆 提交于 2019-12-13 06:26:14
问题 If I create multiple clients by doing this: def main(): clients = [None]*10 for i in range(0, 10): clients[i] = ClientFactory() reactor.connectTCP('192.168.0.1', 8000, clients[i]) reactor.run() How to I -gracefully- stop the reactor? If I do: self.transport.loseconnection() In the protocol, then do: reactor.stop() In the factory, then the next client is going to try to come along a stop the reactor again. However, this of course leads to the error: Can't stop a reactor that isn't running How

Run multiple twisted servers?

血红的双手。 提交于 2019-12-13 06:08:54
问题 Is there some way to run multiple twisted servers simultaneously on the same port? So that they would be listening on different directories (for example: example.com/twisted1 is one twisted script, and example.com/twisted2 is another script) 回答1: You can router your scripts with an web framework, like: Django, Flask, Web2Py... Or, if you prefer you can create an router script for route manually 来源: https://stackoverflow.com/questions/36877127/run-multiple-twisted-servers

Strange behaviour when trying to implement twisted deferredlist

女生的网名这么多〃 提交于 2019-12-13 02:37:32
问题 I'm new to twisted and trying to build a simple POC, however I keep getting the following error. running [] running [] running [] running [] running [] Traceback (most recent call last): File "./poc.py", line 23, in <module> dl = defer.DeferredList([tasks]) File "/usr/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 820, in __init__ deferred.addCallbacks(self._cbDeferred, self._cbDeferred, AttributeError: 'list' object has no attribute 'addCallbacks' I have been reading

Threading with Twisted with Tkinter

瘦欲@ 提交于 2019-12-13 01:13:17
问题 I am currently working on a Battleship game project (for learning purposes) that uses tkinter for the UI and, because I want this program to be able to run on two computers for multiplayer, twisted for data transfer. This is my first time using twisted however I have used tkinter many times. I know both twisted and tkinter run in loops so it is normally not possible to have these running in the same thread. So I found out there's two ways to get around this: tksupport and running twisted's

I have a twisted reactor running, how do I connect to it?

人走茶凉 提交于 2019-12-12 23:03:57
问题 I've been following the tutorials and now have a twisted reactor running. I've used telnet to test that it does stuff but I've not managed to find anything in the twisted tutorials on how to connect to the reactor. My assumption was there would be something within twisted to do this, should I instead use the built in socket? Edit: This is the Server script: import time import multiprocessing from twisted.internet.protocol import Factory from twisted.protocols.basic import LineReceiver from

Verify SSL/X.509 certificate is signed by another certificate

时光怂恿深爱的人放手 提交于 2019-12-12 22:17:10
问题 Question How can I verify that an X.509 certificate is signed by another certificate using PyOpenSSL or Twisted? I want a client to verify that the received server certificate is the one that signed its client certificate. I've looked through the PyOpenSSL documentation and can't seem to find anything on how to verify a certificate separately from the establishing the SSL connection. I found a reference to OpenSSL.crypto:X509.verify() in twisted.internet._sslverify:PublicKey.verifyCertificate

Running Portia (scrapy) on Windows

好久不见. 提交于 2019-12-12 20:18:32
问题 I have succefully installed Portia on Windows 8.1 according to this guide http://doc.scrapy.org/en/latest/intro/install.html#windows (used pip instead of easy_install). When starting slyd via twistd.py -n slyd everything seems to work fine until I open the website http://localhost:9001/static/main.html . The following error is displayed in the console window: 2014-06-03 19:05:56+0200 [-] Log opened. 2014-06-03 19:05:56+0200 [-] twistd 14.0.0 (C:\Python27\python.exe 2.7.7) starting up. 2014-06