twisted

Twisted: number of client connections to TCP server limited?

有些话、适合烂在心里 提交于 2019-12-07 15:38:08
问题 I'm writing a chat server and encountered the following problem while unit testing it. In one of my unit tests, I connect many test clients to my server. As the number of connected users get to 511 the server stops responding without any error message. At this stage everything runs locally on a PC. I have prepared a simple server, test client and unit test code to paste into the forum. Any idea why the server hangs up? Any help is much appreciated This code is basicly from the twisted simple

What exactly is wrong with using pymongo in twisted?

◇◆丶佛笑我妖孽 提交于 2019-12-07 12:38:58
问题 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

Testing twisted protocol

喜你入骨 提交于 2019-12-07 11:55:07
问题 I have a very basic client and server protocols developed using Twisted . Twisted allows to unittest them independently and provides nice testing utils such as the StringTransport for this. However, let's say I want to test the protocol works fine. For instance, I want to test that when the server receives a certain message, it will reply to the client in some specific way. What is the best way to do that using trial and the utils in Twisted? I am currently launching processes to run them,

twisted log level switch

好久不见. 提交于 2019-12-07 11:19:20
问题 Is there any way in Twisted how to change logging level of messages which should be logged? I am using three levels in project: log.msg('agent nr.1 has free slots', logging.DEBUG) # debug message log.msg('agent nr.1 has free slots') # info message log.err('agent nr.1 has free slots') # error message And I configure logging in this way: from twisted.python import log from twisted.python.logfile import LogFile logfile = LogFile("someFile.log", '/some/path/', rotateLength=1000, maxRotatedFiles

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

家住魔仙堡 提交于 2019-12-07 10:51:45
问题 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). 回答1: You can use the

Unicode exception in twisted

核能气质少年 提交于 2019-12-07 08:44:42
问题 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

Twisted Python How To Create a twisted.web.client.BrowserLikePolicyForHTTPS with a custom trustRoot?

北城余情 提交于 2019-12-07 07:11:38
问题 I am trying to create a t.w.c.BrowserLikePolicyForHTTPS to use as the ContextFactory for a t.w.c.Agent . I am using an internal CA for all the servers I want the Agent to communicate with, so I'd like to be able to tell to load the CA cert (PEM format) and use it as the trustRoot argument to BrowserLikePolicyForHTTPS . I have read the docs and looked at the source, but I have no idea what I am supposed to supply as arguments. I tried providing a PyOPenSSL x509 object, but I get an error:

How make a twisted python client with readline functionality

女生的网名这么多〃 提交于 2019-12-07 06:38:16
问题 I'm trying to write a client for simple TCP server using Python Twisted. Of course I pretty new to Python and just started looking at Twisted so I could be doing it all wrong. The server is simple and you're intended to use use nc or telnet. There is no authentication. You just connect and get a simple console. I'd like to write a client that adds some readline functionality (history and emacs like ctrl-a/ctrl-e are what I'm after) Below is code I've written that works just as good as using

Python OSX $ which Python gives /Library/Frameworks/Python.framework/Versions/2.7/bin/python

巧了我就是萌 提交于 2019-12-07 05:25:40
问题 Hello I'm trying to run twisted along with python but python cannot find twisted . I did run $pip install twisted successfully but it is still not available. ImportError: No module named twisted.internet.protocol It seems that most people have $which python at /usr/local/bin/python but I get /Library/Frameworks/Python.framework/Versions/2.7/bin/python May this be the issue? If so, how can I change the PATH env? 回答1: It is just fine. Python may be installed in multiple places in your computer.

How can I use a raw_input with twisted?

徘徊边缘 提交于 2019-12-07 03:08:06
问题 I am aware that raw_input cannot be used in twisted. However here is my desired application. I have an piece of hardware that provides an interactive terminal serial port. I am trying to connect to this port and send commands in an async manner. I need it this way because this is a motor controller that once I issue a command it will "block" and run away (my current code). I need to be able to enter another command such as ESTOP in case of problems or danger. I have read some stuff about