gtk - Run a function every X minutes - Python -


I am using Python and PGTK I am interested in running a certain function, which receives data from serial port And it saves it every few minutes.

Currently, I am using the sleep () function in the time library. To be able to process, I have the installation of my system:

  import time time = 300 # 5 minutes while (1): time 1 = time.time () reader ( ) # Read data from serial port processing () # Accessories with serial data, in which time to dump the file 2 = time.time Time () Processing time = time 2 - time 1 truth = weighty - processing time. Sleep (salvage)  

This setup allows me to interrupt the 5-minute reading of data from the serial port. My problem is that I want to stop my readerial () function which is running every 5 minutes and wants to be able to work all the time instead of using time. Sleep () function.

Any suggestions on how to solve this problem? Multiple threading? Comes in between? Please keep in mind that I am using Python.

Thank you.

Do not use such loops with two sleep, this is the gtk timer eg.

  will prevent gtk from processing any UI event instead of using def my_timer (* args). Long gtk.timeout_add (60 * 1000, my_timer) # call every minute  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -