SORU
22 Aralık 2011, PERŞEMBE


Python ile yürütülen periyodik eylemler

Windows üzerinde çalışıyorum. Bir fonksiyonu çalıştırmak istiyorum() fooher 10 saniyede bir.

Bunu nasıl yapabilirim?

CEVAP
22 Aralık 2011, PERŞEMBE


foo(), sonunda oluşturmak 10 saniye sonra foo() kendini çağıran Timer.
Çünkü, Timer foo() arama thread Yeni oluştur.
Bloke olmadan başka şeyler yapabilirsiniz.

>>> import time, threading
>>> def foo():
...   print(time.ctime())
...   threading.Timer(10, foo).start()
...
>>> foo()
Thu Dec 22 14:46:08 2011
>>> Thu Dec 22 14:46:18 2011
Thu Dec 22 14:46:28 2011
Thu Dec 22 14:46:38 2011

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • buttheadgsxr1000

    buttheadgsxr

    24 Ocak 2008
  • L33TNoonProductions

    L33TNoonProd

    24 EYLÜL 2010
  • Top10Series

    Top10Series

    26 Kasım 2008