Dear twisted-python,
I’m trying to integrate a python REPL into my existing twisted 8.2.0
client-side program (which talks to another twisted server running a custom
protocol). This client side program uses twisted.internet.stdio.StandardIO
already to interact with the user, to read commands from the user and send
them to the server. What’s the best way to add functionality to drop into a
python REPL? I adapted the doc/core/examples/stdin.py code below to drop
into the ‘code’ stdlib module to try to model for the mailing list what my
larger client program is trying to do. It works fine on linux, until you
enter a command which outputs a large amount of data, at which point you get
a “Resource temporarily unavailable” as can be seen below. I’m assuming the
issue is related to StandardIO taking control of reads/writes to the stdio
file descriptors, and not integrating well with python code that writes
directly to sys.stderr, but I’m not sure what the right solution is. I
don’t mind that the call to ‘code.interact()’ blocks the reactor for my use
case, but I don’t mind if better solutions are available which don’t have
that problem, either.
Modified doc/core/examples/stdin.py:
---------------------------------------
"""
An example of reading a line at a time from standard input
without blocking the reactor.
"""
from twisted.internet import stdio
from twisted.protocols import basic
class Echo(basic.LineReceiver):
from os import linesep as delimiter
def connectionMade(self):
self.transport.write('> ')
def lineReceived(self, line):
self.sendLine('Echo: ' + line)
self.transport.write('> ')
import code
code.interact()
def main():
stdio.StandardIO(Echo())
from twisted.internet import reactor
reactor.run()
if __name__ == '__main__':
main()
---------------------------------------
A sample run:
$ ./twisted-stdio.py
> foo
Python 2.6.1 (r261:67515, Jun 4 2009, 11:06:31)
[GCC 4.1.2 20071124 (Red Hat 4.1.2-43)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> 11 * 'x'
'xxxxxxxxxxx'
>>> 11111 * 'x'
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTraceback
(most recent call last):
File "/sw/external/twisted-8.2.0/lib/python/twisted/python/log.py", line
84, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/sw/external/twisted-8.2.0/lib/python/twisted/python/log.py", line
69, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/sw/external/twisted-8.2.0/lib/python/twisted/python/context.py",
line 59, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/sw/external/twisted-8.2.0/lib/python/twisted/python/context.py",
line 37, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File
"/sw/external/twisted-8.2.0/lib/python/twisted/internet/selectreactor.py",
line 146, in _doReadOrWrite
why = getattr(selectable, method)()
File "/sw/external/twisted-8.2.0/lib/python/twisted/internet/process.py",
line 242, in doRead
return fdesc.readFromFD(self.fd, self.dataReceived)
File "/sw/external/twisted-8.2.0/lib/python/twisted/internet/fdesc.py",
line 70, in readFromFD
callback(output)
File "/sw/external/twisted-8.2.0/lib/python/twisted/internet/process.py",
line 245, in dataReceived
self.proc.childDataReceived(self.name, data)
File
"/sw/external/twisted-8.2.0/lib/python/twisted/internet/_posixstdio.py",
line 73, in childDataReceived
self.protocol.dataReceived(data)
File "/sw/external/twisted-8.2.0/lib/python/twisted/protocols/basic.py",
line 231, in dataReceived
why = self.lineReceived(line)
File "./twisted-stdio.py", line 27, in lineReceived
code.interact()
File "/sw/external/python-2.6.1/lib/python2.6/code.py", line 306, in
interact
console.interact(banner)
File "/sw/external/python-2.6.1/lib/python2.6/code.py", line 243, in
interact
more = self.push(line)
File "/sw/external/python-2.6.1/lib/python2.6/code.py", line 265, in push
more = self.runsource(source, self.filename)
File "/sw/external/python-2.6.1/lib/python2.6/code.py", line 87, in
runsource
self.runcode(code)
File "/sw/external/python-2.6.1/lib/python2.6/code.py", line 107, in
runcode
self.showtraceback()
File "/sw/external/python-2.6.1/lib/python2.6/code.py", line 162, in
showtraceback
map(self.write, list)
File "/sw/external/python-2.6.1/lib/python2.6/code.py", line 171, in write
sys.stderr.write(data)
exceptions.IOError: [Errno 11] Resource temporarily unavailable
My colleague discovered the below workaround which temporarily changes the
nonblocking status of sys.stderr (and restores it afterwards), but feels
like a hack which violates across abstraction layers and which might not
work correctly in future versions of twisted:
+ import fcntl
+ oldval = fcntl.fcntl(sys.stderr.fileno(), fcntl.F_GETFL)
+ fcntl.fcntl(sys.stderr.fileno(), fcntl.F_SETFL, oldval & ~os.O_NONBLOCK)
code.interact()
+ fcntl.fcntl(sys.stderr.fileno(), fcntl.F_SETFL, oldval)
So, any tips on integrating a REPL into our existing program without
resorting to this hack would be appreciated! Thanks.
--
Benjamin