Running Python code in "background"

  • I'm looking for a way to run some processing code in background in Enigma2. So far with little luck.


    Simply using threading appears to be 'disabled' when running from Enigma2 (works file in a standalone Python process though).


    I tried using the reactor, which helps a bit, but the program needs a lot of processing for small amounts of data, so the UI becomes sluggish and i still get the rotating wheels. Besides that, it's a real pain in the youknowwhere to have to revert all code from pulling data (read) to being pushed.


    Running the code from another process is an option, but it wastes a lot of precious RAM on copies of things that are already loaded into Enigma2, and it makes communication with the background process more complicated.


    I wonder what else I can do. I also considered creating the thread in C++ code and calling back into my Python code from there, so that the Python processing part also runs on that thread. Would that be an option?
    Another thing that came to mind was a sort of "Idle" call, which calls a method when the reactor is idle, so that code there can execute in little bits (windows 3.1 style multitasking).


    Any takers?

  • I also considered creating the thread in C++ code and calling back into my Python code from there, so that the Python processing part also runs on that thread. Would that be an option?

    Yeah sure, why not.
    I used c++ code with callbacks in MerlinMP3 Player e.g., and used in c++ code non-blocking threads, it works great. No blocking in Enigma2 at all...