Hello, On Sat, Apr 9, 2011 at 11:05 AM, anatoly techtonik <[email protected]> wrote: > Hi, > Can anybody explain how is the main cycle/loop of bpython supposed to work? > I am on Windows and don't know curses specifics. What happens (or should > happen) at initialization, how the main loop starts and what should happen > when you press the key? Is waiting for a key synchronous or not?
There is not really "the" mainloop, we use different mainloops for different UIs. Note that the long-term plan is to get rid of curses entirely and use urwid instead. Marien Zwaart contributed the urwid UI for bpython, which is already in a very nice shape. In the case of curses, the "repl" method of "bpython.cli.CLIRepl" is the mainloop. It waits for input synchronousely, but we use some trick (ungetch(), to be precise) to interrupt the blocking call when needed (e.g. while we are building the module cache during startup). The urwid UI uses the the urwid mainloop and gets input asynchronously. It can also use a Twisted mainloop, which is rather nice (ie it can run Twisted plugins). The gtk UI uses the gtk mainloop and hence also gets the input asynchronously. In all cases, the initialisation is done in the corresponding main functions. They set up the UI frameworks and instantiate the REPL itself and finally run it. They also prepare the Python interpreter itself (e.g. replacing sys.stdout). Some not so specific stuff like argument parsing is factored out into its own module (bpython.args). HTH, Andreas -- You received this message because you are subscribed to the Google Groups "bpython" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/bpython?hl=en.
