0

I have an event based application where I select() on various things and depending on what gets selected, the application handles it. To add to this, I want to add an interactive menu implemented in python. In a typical update() (called from within while(!done) loop):

- while(!done) {
   select() with timeout
   give control to python menu with timeout
}

Also, I don't want to run the python menu on a separate thread since it brings alongwith it the issue of race conditions and due to the nature of code/application/customers, I cannot have locks in the part of the code where the menu interacts. So, it has to be done in a single threaded environment.

I have been reading online but I couldn't find a way to do this in single threaded environment with a timeout. Can anyone please point me in the right direction or any pointers on how to do this ?

brainydexter
  • 19,826
  • 28
  • 77
  • 115
  • I guess a question would be, what is your menu implemented in, and how are you trying to call into Python? Most GUI frameworks have an API call that can "run single timeslices" for this exact purpose. – Mark Nunberg Oct 23 '14 at 02:13
  • @mnunberg menu is implemented in python. Menu may be misleading to believe it is a GUI menu. It is not. It's a text based commandline menu, where user is presented with options 1-6 to choose from and we do something specific based on what option is selected. – brainydexter Oct 27 '14 at 21:07
  • So `menu` is a simple stdin loop? – Mark Nunberg Oct 27 '14 at 21:30
  • yes, only that it is written in python using `cmd`[https://docs.python.org/2/library/cmd.html] – brainydexter Oct 28 '14 at 00:50

0 Answers0