hi there, folks:
I'd really like to release 0.7.0 but I would like it to be at least a
little bit tested before I do so. Could those of you with CVS trees check
everything out and see if it performs as advertised? Deeper bugs than
that will have to wait for the next release, but I'd at least like to know
if it works for someone other than me.
______ __ __ _____ _ _
| ____ | \_/ |_____] |_____|
|_____| |_____ | | | |
@ t w i s t e d m a t r i x . c o m
I have a twisted TCP server to listens to client, processes requests, do
mysql database operations if needed (using adbapi Connection pool) and
return the result. Before deploying this in production, I want to know
right way to configure the server.
Since twisted is single threaded, how can I leverage multiple cores of my
production machine (which has 6 cores and 16 GB RAM) ?
One approach that I thought of was to start multiple instances of twisted
server on different ports. This would help in using the other cores as
well. What do you guys suggest ?
I would like to announce txZMQ, ZeroMQ bindings for Twisted. txZMQ is based
on pyzmq and requires recent ØMQ version (>=2.1).
txZMQ uses ØMQ APIs to get file descriptor that is used to signal pending
actions from ØMQ library IO thread running in separate thread. txZMQ should
be usable with any Twisted reactor.
* The socket library that acts as a concurrency framework.
* Carries messages across inproc, IPC, TCP, and multicast.
* Connect N-to-N via fanout, pubsub, pipeline, request-reply.
* Fast enough for clustered products and supercomputing.
* Asynch I/O for scalable multicore message-passing apps.
Bridging ØMQ and Twisted makes a nice match: fast simple messaging between
Twisted instances solving complex problems :)
* PyPi: http://pypi.python.org/pypi/txZMQ/
* Source code: https://github.com/smira/pyzmq
* pyzmq: http://pypi.python.org/pypi/pyzmq
* ØMQ: http://www.zeromq.org/
Qik Web Team Lead
Crochet is an MIT-licensed library that makes it easier to use Twisted
from regular blocking code. Some use cases include:
* Easily use Twisted from a blocking framework like Django or Flask.
* Write a library that provides a blocking API, but uses Twisted for
* Port blocking code to Twisted more easily, by keeping a backwards
* Allow normal Twisted programs that use threads to interact with
Twisted more cleanly from their threaded parts. For example this can
be useful when using Twisted as a WSGI container.
This is a bugfix release, recommended for all users of Crochet.
Crochet can be downloaded from https://pypi.python.org/pypi/crochet or
$ pip install crochet
Documentation can be found at http://crochet.readthedocs.org
Bugs and feature requests should be filed at the project
Here’s an example of a program using Crochet. Notice that you get a
completely blocking interface to Twisted and do not need to run the
Twisted reactor, the event loop, yourself.
Do a DNS lookup using Twisted's APIs.
from __future__ import print_function
# The Twisted code we'll be using:
from twisted.names import client
from crochet import setup, wait_for
# Crochet layer, wrapping Twisted's DNS library in a blocking call.
"""Lookup the IP of a given hostname.
Unlike socket.gethostbyname() which can take an arbitrary amount of time
to finish, this function will raise crochet.TimeoutError if more than 5
seconds elapse without an answer being received.
d = client.lookupAddress(name)
d.addCallback(lambda result: result.payload.dottedQuad())
if __name__ == '__main__':
# Application code using the public API - notice it works in a normal
# blocking manner, with no event loop visible:
name = sys.argv
ip = gethostbyname(name)
print(name, "->", ip)
Run on the command line:
> $ python blockingdns.py twistedmatrix.com
> twistedmatrix.com -> 184.108.40.206
Today I wrote an endpoint parser for Meejah's txtorcon Tor Hidden
Now that we have foolscap ported to twisted endpoints (branch needs
review but I should probably rebase first) we'd like to be able to
simply specify an "onion" endpoint descriptor in Tahoe-LAFS
configuration... that way foolscap receives the descriptor and uses
serverFromString to generate the endpoint object.
This will work fine for the txsocksx tor client endpoint parser I
wrote... However the txtorcon Tor Hidden Service endpoint setup
requires a deferred to fire once the tor process is started... This
means that the endpoint parser needs to return a deferred. But this
breaks the interface!... meaning that foolscap or any other api using
this onion endpoint parser will have to special case the situation
where serverFromString returns a deferred.
Terrible! Or do you think this is not so terrible?
I am curious to know your thoughts and if any of you have alternate
solutions... since I am obviously doing it wrong.
Here's my txtorcon onion endpoint parser:
And here's some example code that uses it:
By the way (just in case you don't know)... you can test this parser
by placing it in the twisted/plugins directory... here's how I do it:
usewithtor pip install twisted
git clone https://github.com/david415/txtorcon.git
# defaults to my endpoint_parser_plugin branch
usewithtor python setup.py install
cd examples # CWD is now /home/human/projects/txtorcon/examples
# and then run the example code that uses this endpoint parser
I have some Klein code that uses deferToThread for I/O. It looks something
def index(request, *args, **kwargs):
d = deferToThread(some_blocking_db_select_function)
I have a test that executes this function, and the deferToThread returns a
Deferred, but that deferred never fires its callback, and so when I use
successResultOf expecting a success result, no result is found.
When I use twistd to run the Klein application, everything works fine (the
deferred fires and I get a json string in the body of the response). What's
different about the trial environment that deferToThread might not fire its
callback? Do I need to explicitly set up a thread pool in trial that I
don't have to set up using twistd? Any help would be appreciated.
i have written a script to send email by using the twisted smtplib
in which i am trying to import the ESMTPSenderFactory from
twisted.mail.smtp. but its giving the error as import error : no module
name mail.smtp. so please someone help me to get rid of this error. i am
using python 2.7 in ubuntu 13.10.