From 19a326c401362f64f00fae668542e46db81d5261 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Fri, 24 Oct 2008 19:28:24 +0700 Subject: [PATCH] twisted callbacks are run in the mainloop greenlet and therefore shouldn't block. fixed example to use spawn --- examples/twisted_ex2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/twisted_ex2.py b/examples/twisted_ex2.py index 5ece6cf..6c7cf88 100644 --- a/examples/twisted_ex2.py +++ b/examples/twisted_ex2.py @@ -5,6 +5,7 @@ from twisted.protocols import basic from twisted.internet import reactor from twisted.internet.error import ConnectionDone +from eventlet.api import spawn from eventlet.channel import channel from eventlet.twisteds.util import block_on @@ -12,7 +13,7 @@ from eventlet.twisteds.util import block_on class LineOnlyReceiver(basic.LineOnlyReceiver): def lineReceived(self, line): - self.channel.send(line) + spawn(self.channel.send, line) def connectionLost(self, reason): self.channel.send_exception(reason.value)