Skip to content

Instantly share code, notes, and snippets.

@kurtbrose
Last active December 27, 2015 00:49
Show Gist options
  • Select an option

  • Save kurtbrose/7240973 to your computer and use it in GitHub Desktop.

Select an option

Save kurtbrose/7240973 to your computer and use it in GitHub Desktop.
greenlet based REPL -- note dependent on 1.0 gEvent which adds the fileobject module
import sys
import code
from gevent import fileobject
_green_stdin = fileobject.FileObject(sys.stdin)
_green_stdout = fileobject.FileObject(sys.stdout)
def _green_raw_input(prompt):
_green_stdout.write(prompt)
return _green_stdin.readline()[:-1]
def run_console(local=None, prompt="GREEN REPL"):
code.interact(prompt, _green_raw_input, local=local or {})
if __name__ == "__main__":
run_console()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment