Skip to main content

threading.Thread类的继承和拓展

Project description

这个模块只要包括两个类:

 一 ThreadEx:

ThreadEx 类 继承了常用模块 threading 的 Thread 类 完整继承了Thread的6个参数: group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None 新增了方法: 暂停线程 恢复线程 强制停止线程 新增了: 线程状态属性 self.status 新增了: 系统级别线程id属性 self.tid: 系统级别的id 这个 类创建的 对象 python thread类对象,通常也称为 线程id 他是 thread操作的句柄对象。 这里我在执行thread对象时候执行获取了线程在系统里面的id 然后通过系统api 根据 系统里面的线程id来控制线程的 暂停 停止 继续,结束 。这里对于默认的Thread 线程类的继承

总结: 这个类适合 创建 操作 单个线程, 如果需要多个线程同时操作,可以使用 ThreadManage 类来实现更高级的功能。

二 ThreadManage:

调用 ThreadEx 类。 创建对象 创建对象时候每一次创建都会被记录线程id到ThreadManage的全局列表中, 后续使用这个列表对所有线程进行批量管理 可以批量停止全部线程,暂停全部线程,恢复全部线程运行。 这个类适合在需要管理多个线程时候使用

pip 安装: 

" pip install NewThread "

更新:
1.01 版本做了部分更新。优化。增加了 停止单个线程的功能。
1.02 版本新增了 清理 线程列表功能,防止线程列表 成员 在极端情况下会 一直增加

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

NewThread-1.0.2.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file NewThread-1.0.2.tar.gz.

File metadata

  • Download URL: NewThread-1.0.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.20 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.5

File hashes

Hashes for NewThread-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d14a43903521827c05b042521e97e5d0ebf7f0c71507e7ed419ac91a2c26012e
MD5 24e4c7a34a41f09f98c71030f425402b
BLAKE2b-256 00d0716e6e302b2e6c625c59ef8d98f8fd89ebd20256b35ad02a422db7eaebfc

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