twisted

Python Twisted WebSocket client

∥☆過路亽.° 提交于 2019-12-05 19:09:06
问题 Having worked with Twisted in the past I'd like to know if there is a way to get WebSocket client support to work. Looking around the documentation I can only find server implementations. 回答1: Tavendo Autobahn is a very featureful websockets implementation. One of those features is a Python WebSockets client with Twisted support. 来源: https://stackoverflow.com/questions/8096237/python-twisted-websocket-client

What exactly is wrong with using pymongo in twisted?

好久不见. 提交于 2019-12-05 18:29:35
I have a twisted server application that maintains persistent connections with around 1000 clients. Each client will occasionally send data to my twisted server, and I would like that server to store data into a MongoDB database. So far, so good. But, the pymongo documentation states something like "there is no good way to use pymongo with twisted". I don't understand why not. Can someone please explain what exactly the problem is and what the pitfalls are? I think it has something to do with pymongo being synchronous, but all I want to do is shove some stuff into the database. If I have a

Which way to go with twisted and web-programming?

泪湿孤枕 提交于 2019-12-05 18:22:43
问题 So, I programmed this twisted application a few months ago, which I now would like to extend with a web-based user interface for configuration. The Twisted website recommends Nevow, but I am not really sure if this is a good choice. Their website is down for a while it seems and their launchpad page hadn't seen any update in half a year. Is this project dead? Additionally I have seen discussion of moving parts of Nevow into twisted.web on the twisted-web mailinglist. So, is it still

Python application using Twisted stops running after user logs off of Windows XP

倖福魔咒の 提交于 2019-12-05 18:05:19
I inherited a project using the Twisted Python library. The application is terminating after the user logs off of Windows XP. The Python code has been converted to an executable using bbfreeze. In addition, the bbfreeze generated executable is registered as a Windows service using the instsrv.exe and srvany.exe. I've taken a simple chat example from the Twisted website and create an executable from bbfreeze and registered it with instsrv and srvany and the same problem occurs: the executable stops running after the user logs off. I'm inclined to think that something about Windows XP and the

redirect http to https in twisted

早过忘川 提交于 2019-12-05 17:59:32
I'm running a django app using twisted. I moved now from http to https. How can I add redirects from http to https in twisted? Jean-Paul Calderone An easy way to generate redirects in Twisted Web is is with the Redirect resource. Instantiate it with a URL and put it into your resource hierarchy. If it is rendered, it will return a redirect response to that URL: from twisted.web.util import Redirect from twisted.web.resource import Resource from twisted.web.server import Site from twisted.internet import reactor root = Resource() root.putChild("foo", Redirect("https://stackoverflow.com/"))

Why does scrapyd throw: “'FeedExporter' object has no attribute 'slot'” exception?

南楼画角 提交于 2019-12-05 16:16:12
I came across a situation where my scrapy code is working fine when used from command line but when I'm using the same spider after deploying (scrapy-deploy) and scheduling with scrapyd api it throws error in "scrapy.extensions.feedexport.FeedExporter" class. one is while initializing "open_spider" signal second is while initializing "item_scraped" signal and last while "close_spider" signal 1."open_spider" signal error 2016-05-14 12:09:38 [scrapy] INFO: Spider opened 2016-05-14 12:09:38 [scrapy] ERROR: Error caught on signal handler: <bound method ?.open_spider of <scrapy.extensions

Good Python networking libraries for building a TCP server?

只愿长相守 提交于 2019-12-05 15:57:07
问题 I was just wondering what network libraries there are out there for Python for building a TCP/IP server. I know that Twisted might jump to mind but the documentation seems scarce, sloppy, and scattered to me. Also, would using Twisted even have a benefit over rolling my own server with select.select()? 回答1: I must agree that the documentation is a bit terse but the tutorial gets you up and running quickly. http://twistedmatrix.com/projects/core/documentation/howto/tutorial/index.html The

Unicode exception in twisted

笑着哭i 提交于 2019-12-05 15:39:33
On my production server I have periodically happening unicode error but not on my desktop. It appears in logs: 2011-03-17 13:14:53+0000 [GameProtocol,941,95.78.43.17] <unicode instance at 0x9e304a0 with str error: Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/twisted/python/reflect.py", line 546, in _safeFormat return formatter(o) UnicodeEncodeError: 'ascii' codec can't encode characters in position 21-26: ordinal not in range(128) > It doesn't affect any logic in application but it's annoying in logs. The server runs under Ubuntu 10.10 Server, Python 2.6.5,

Can writing to a UDP socket ever block?

三世轮回 提交于 2019-12-05 15:03:54
问题 And if so, under what conditions? Or, phrased alternately, is it safe to run this code inside of twisted: class StatsdClient(AbstractStatsdClient): def __init__(self, host, port): super(StatsdClient, self).__init__() self.addr = (host, port) self.server_hostname = socket.gethostname() self.udp_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) def incr(self, stat, amount=1): data = {"%s|c" % stat: amount} self._send(data) def _send(self, data): for stat, value in data.iteritems(): self

Twisted log rotation by size / having an upper limit on the total number of files?

╄→尐↘猪︶ㄣ 提交于 2019-12-05 14:53:02
I have a twisted server that generates log files and rotates them based on size. If the file size of a particular file is more than 1MB, a new log file is created. However, after several days of running, the log files start filling up my hard disk. Is there a way to have an overall limit on log rotation? The limit could be based on total size (like only 200GB worth of logs - anything more would be deleted), or on the number of files (like only 1000 logs would be stored). You can use the option logger. You will have to write your own logger factory, something like this #in module mymodule, file