Skip to main content

计时器池管理器, 将多个计时器挂在到计时器管理器中, 用一个线程来统一管理, 减少资源消耗

Project description


计时器池管理器
作用:
将多个计时器挂在到计时器管理器中, 用一个线程来统一管理, 减少资源消耗
别的多线程计时器在线程切换时会造成额外资源消耗
管理线程会根据在创建第一个计时器时自动启动, 关闭最后一个计时器后自动关闭
注意:
尽量不要调用Timer_Manager()中的close(), add_timer(), remove_timer()函数, 除非你真的完全了解这个模块
在计时器回调函数中调用close(), add_timer(), remove_timer()函数会造成死锁

测试代码:
if __name__ == '__main__':
def fun1(t: Timer):
print('回调', t.meta, t.callback_count, time.strftime(' %H:%M:%S', time.localtime()))


def fun_de(t: Timer):
print(t.meta, '关闭')


import time

t1 = Timer(fun1, 1, 5, close_callback=fun_de, meta='计时器1 ')
t1.start()

time.sleep(0.5)
t2 = Timer(fun1, 1, 2, meta=' 计时器2 ')
t2.start()

print('等待计时器1结束')
t1.join()
print('结束')


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ztimer-1.0.5.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ztimer-1.0.5-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file ztimer-1.0.5.tar.gz.

File metadata

  • Download URL: ztimer-1.0.5.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for ztimer-1.0.5.tar.gz
Algorithm Hash digest
SHA256 e8d3dcdaa61d2f839c367a692e30ad0cb9178a34514a80f263b1eb6ffec4e7fe
MD5 8b9c14899b3de12705202ec53904155f
BLAKE2b-256 01d2724749d5901ebef4514a37967ce1203e612dc25704aa03736dbf6aba39cb

See more details on using hashes here.

File details

Details for the file ztimer-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: ztimer-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for ztimer-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0cd47e143ca851b6590fed3462d93d6ca318e150447e8bdd98a71634625c373e
MD5 d4df49083517ce397f413b7e39cb017f
BLAKE2b-256 84645308e7e7a351b91a1c230a76d709f8791d4af7ba3c54dc12fbedff9a3be8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page