title: Write on CSV file every 10 seconds
body: <p>I am writing a code that should update an empty .csv file with rows containing two columns every 10 seconds. One column containing an integer that indicates time e.g. [0,10,20,30 etc.] with an increase of 10 each time the <code>initial_time = initial_time + 10</code> is called (the reason for this is to denote time in 10 seconds intervals for plotting purposes later on), and the second column holding integer contents from count which is constantly updated in a <code>while(True)</code> loop.</p>
  <p>I cannot use <code>sleep</code> function because I need a program to run without a halt, and I'm curious if there is a way of doing so without the use of the threading module.</p>
  <p>This is the general code format:</p>
  <pre><code>import cv2
  import csv
  
  c = open('test.csv', 'w', newline='')
  collect_data = csv.writer(c, delimiter=',')
  
  count = 0
  initial_time = 0
  
  def data_collection():
      global initial_time
      collect_data.writerow([initial_time, count])
      initial_time = initial_time + 10
  
  def other_functions():
  
  while(True):
      other_functions()
  
      data_collecion()
  
      for () in something:
  
      conditions here 
  
          if(condition):
              count=count+1
      
          more_functions()
          key=cv2.waitKey(1)
  
      if key==27:
          break
  
  c.close()
  </code></pre>