I want to execute part of my code exactly at the same time every time I execute it, something like playing a media file ... (the same piece of code is executed exactly the same amount of time each time)
Is this possible in python?
This should do the trick:
def run_with_delay(funcs, interval): for f in funcs[:-1]: before = time() f() # compensate the interval with the execution time. # NB: careful for functions that have a greater # execution time than interval after = time() if after - before < interval: sleep(interval - (after - before)) # last function is taken separately because we don't need # an extra useless sleep funcs[-1]()
I do not think that this can be guaranteed by the construction of the language (in any language) - you must be in the real-time operating system. I believe that multimedia applications use device-level buffering to compensate for jitter in the OS process scheduler.
, , .
Source: https://habr.com/ru/post/1785646/More articles:What is the bootloader for Caliburn Micro - wpfValidators Post in Rails 3 - validationThe problem of multitexturing (beginner) - opengl-esmonitoring in mysql - mysqlXel Deserialization - после неизвестного node в xml-данных все поля остаются пустыми - c#How to set Haskell-0.6.3 module encoding on windows? - encodinghttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1785648/marshalling-simple-and-complex-datatypes-tofrom-object-void&usg=ALkJrhjzDTE47B2iK-wBvublhs4UkRAOSgPassing parameters back and forth between forms in C # - c #Проверка подлинности источника данных Перед тем, как продолжить - coldfusionКак мог этот код вести себя так, как я видел? - c++All Articles