python - How to structure code to be able to launch tasks that can kill/replace each other -


i have python program following: 1) endlessly wait on com port command character 2) on character reception, launch new thread execute particular piece of code

what need if new command received is: 1) kill previous thread 2) launch new one

i read here , there doing not right way proceed. best way knowing need in same process guess need use threads ...

i suggest 2 differente approaches:

  • if processes both called internally function, set timeout on first function.
  • if running external script, might want kill process.

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -