How to run a Background task in a separate thread.

  • Hello,


    I want to do some processing which cannot take place in the main thread. The processing I want to run in background is basically something like:


    Code
    while 1:
      d = file.read(64)
      songname = d
      d.file.read(buffersize)
      pipe.write(d)


    (the pipe goes to the MP3 decoder, that part is working just fine)


    I saw something about timers, which is rather clumsy to use here, as the code will be cluttered with all kind of clumsy things to prevent blocking the main thread waiting for incoming data, while still feeding the pipe fast enough...


    The current solution is to have another process that runs that "processing", but that is much harder to use, and it's a pain somewhere to communicate with the background process, while a thread is exactly what i want here...


    I tried using Python threading, that is working just fine outside of Enigma, but when I put the threading code into a plugin, the thread function just never gets called at all. Apparently, Enigma2 plainly refuses to create threads?

    • Offizieller Beitrag

    enigma2 is not built to use python-threads and you should never do so.
    There are several helpers like for example eAppContainer built into enigma2 to help you running everything event-based.

    mfg ,
    Reichi