muti_thread是一个真正的多并发多线程,python3.6
# -*- coding: utf-8 -*-
import sys
sys.path.append(r'E:\algo_text\nn_csdk\build\Release')
import time
from muti_thread.muti_thread import thread_create,thread_append,thread_start_and_join
import numpy as np
vec1 = [1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
vec2 = [5,6,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
def my_compute(n=10000):
for i in range(n):
dist1 = np.dot(vec1, vec2) / (np.linalg.norm(vec1) * np.linalg.norm(vec2))
class thread_param:
def __init__(self,index):
self.counter = 0
self.index = index
#必须有且只有一个参数,最好是某个类的实例
#注意 , 线程函数里最好不要有import的东西 ,里面最好是执行函数
def thread_func(param):
#param.counter += 1
#print(param.index)
#测试1万次
my_compute()
# if param.counter> 10000:
# print(param.index ,'end')
# return -1
# ii = -1
# while ii < 10:
# ii += 1
# print('线程', param.index, ii)
#
# time.sleep(1)
#print(param.index, 'end')
return -1 #// 返回值小于0 退出线程 , 0 继续循环执行线程函数
def main():
resource = thread_create()
#并发线程
for i in range(10):
param = thread_param(i)
thread_append(resource, thread_func, param)
#开始并等待线程结束
start = float(round(time.time() * 1000))
thread_start_and_join(resource)
end = float(round(time.time() * 1000))
print('run time {}'.format (end-start))
if __name__ == '__main__':
main()
Metadata
Release files for muti-thread 1.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| muti-thread-1.1.10.linux-x86_64.tar.gz | 17.9 kB | Without provenance | Details for muti-thread-1.1.10.linux-x86_64.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| muti_thread-1.1.10-py3-none-any.whl | Python 3 | none | any | Details for muti_thread-1.1.10-py3-none-any.whl |
Total release size: 36.2 kB
Release files / muti-thread-1.1.10.linux-x86_64.tar.gz
| Download URL | muti-thread-1.1.10.linux-x86_64.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53b0a00caccd47e91a1a5e149131096ee1b0228c3a700f14f20f2a4b026c5089
|
|
BLAKE2b-256 checksum How to use checksums |
c43380505e62f57c0a7530296ac36cfa7382c666c1908af3f92acee8d1e63809
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.9
|
Release files / muti_thread-1.1.10-py3-none-any.whl
| Download URL | muti_thread-1.1.10-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76f6d39a5a93f7e866a4f03664ba26298cf2f7210a2efffd8b7d8ca4d2c2748c
|
|
BLAKE2b-256 checksum How to use checksums |
a6da58b58fde6597486e2518200b67a5b3cb84f9fc5848136030acc5209aad84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.9
|
Security for muti-thread 1.1.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.