Skip to content

gevent.monkey.patch_sys breaks the arrow keys #274

@bikeshedder

Description

@bikeshedder

I am using gevent in mushroom (https://bitbucket.org/terreon/mushroom) and would like to provide an interactive console using the Python cmd module. Using the new gevent.moneky.patch_sys breaks the arrow keys.


[Update] Shorter example showing the behavior:

from gevent import monkey
monkey.patch_sys()
input()

Example program making use of cli. Just start the application and try pressing theup- and down-arrow keys.

#!/usr/bin/env python2

import cmd

from gevent import monkey


class Cmd(cmd.Cmd):

    def do_exit(self, args):
        '''Exit the console.'''
        return 'exit'

    def do_EOF(self, args):
        '''You can exit the console by typing Ctrl+D.'''
        return 'EOF'

    def do_ping(self, args):
        '''Return "pong".'''
        print 'pong'


if __name__ == '__main__':
    monkey.patch_sys()
    cmd = Cmd()
    cmd.cmdloop()

Expected behaviour: It should be possible to pick a previous command from the history by using the arrow keys.
Actual behavior: It outputs ^[[A and ^[[B.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: cantfixSomething that cannot be changed in gevent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions