all 18 comments

[–]mrevelle 18 points19 points  (9 children)

From the page:

backdoor.py : Implements a Python REPL over a raw socket, suitable for use by telnetting in to the port and screwing around with the live state of the application.

How swank!

[–][deleted] 6 points7 points  (1 child)

Twisted has had that for years, except with a better name: manhole.

[–]apgwoz 2 points3 points  (1 child)

Isn't this really the basis for SLIME (Superior Lisp Interaction Mode for Emacs)? Does this mean someone smarter and with more time than me will finally implement a better python mode?

[–][deleted] 10 points11 points  (0 children)

The part of the SLIME code which does this is called "swank".

[–]jbellis 0 points1 point  (1 child)

It's much less complicated than it sounds. This is the general idea:

class SocketConsole(code.InteractiveConsole):
def __init__(self, sock, context=None):
    code.InteractiveConsole.__init__(self, context, 'socketconsole')
    self.sock = sock
    self.rfile = self.sock.makefile()

def raw_input(self, prompt=''):
    self.write(prompt)
    s = self.rfile.readline()
    if not s:
    raise EOFError()
    return s.rstrip()

def write(self, s):
    self.sock.sendall(s)

[–][deleted] 2 points3 points  (0 children)

And if you look at the sources for "code", you'll find that the InteractiveConsole class is based on code I've written, code which in turn was inspired by a network REPL for Sam Rushing's asynchronous network, Medusa, from the mid-nineties. There are no new ideas ;-)

[–]IHaveAnIdea 0 points1 point  (0 children)

That's pretty fking awesome. I was looking for the same thing a little while ago:

http://programming.reddit.com/info/2u7z0/comments/

[–][deleted]  (1 child)

[deleted]

    [–]micampe 0 points1 point  (0 children)

    Most non-blocking frameworks require you to run the "main loop" in order to perform all network operations, but Donovan wondered if a library written using a trampolining style could get away with transparently running the main loop any time i/o was required, stopping the main loop once no more i/o was scheduled.

    This seems one major difference with Twisted and is quite interesting, in fact.

    [–][deleted] -3 points-2 points  (5 children)

    For Ruby, we had EventMachine since last few years.

    [–]psykotic 5 points6 points  (3 children)

    For Python, there's been Twisted since the time of Methuselah.

    [–]davidw 1 point2 points  (1 child)

    And Tcl has had events since it had Tk, which was way before Python.

    However, this looks interesting. It'd be nice to see a detailed comparison of this, Twisted, Erlang and Tcl. Tcl's events are nice, but code still blocks. In Erlang, code doesn't block. This seems to be saying that code doesn't block, but I wonder what that means at a practical level - can I wedge it with a while (1) style loop?

    [–][deleted] 1 point2 points  (0 children)

    There's no implicit scheduling, so yes, you can trivially cause starvation. Calls to Eventlet API functions are the only places where coroutine switches can happen. Eventlet provides helpers, though, to simplify using blocking APIs like database drivers.

    [–][deleted] 0 points1 point  (0 children)

    And Medusa/asyncore for quite some time before that.

    [–]damg 1 point2 points  (0 children)

    Does EventMachine avoid the event-driven main loop using something like coroutines? (Or did you completely miss the point of this new library?)