-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiThread.py
More file actions
62 lines (54 loc) · 1.73 KB
/
MultiThread.py
File metadata and controls
62 lines (54 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Filename: AutoGetHtrace.sh
# Revision: 1.0
# Date: 2017/08/26
# Author: _IDLER_
# Email: exFAT@foxmail.com
# Website: http://ext4FAT.github.io
# Description: Systrace Helper, elect function data from Systrace's log
# Notes:
# -------------------------------------------------------------------------------
# Copyright: 2017 (c) _IDLER_
# License: GPL
# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
# Import
# -------------------------------------------------------------------------------
import os, re, sys
import ctypes
import math
import codecs
import shutil
import time
import collections
from multiprocessing import cpu_count
from multiprocessing import Process
from multiprocessing import Pool
def myTask(filePath):
time.sleep(1)
print(filePath)
def multiProc(fileList):
cpu = getCpuKernelCount()
memory = getLeftMemory()
processNum = cpu - 1
procPool = Pool(processNum)
for filePath in fileList:
procPool.apply_async(myTask, (filePath,))
procPool.close()
procPool.join()
def getCpuKernelCount():
return cpu_count()
def getLeftMemory():
'''
if platform.system() == 'Windows':
free_bytes = ctypes.c_ulonglong(0)
ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(folder), None, None, ctypes.pointer(free_bytes))
return free_bytes.value/1024/1024/1024
'''
return 0
def main():
multiProc([str(i) for i in range(0, 100)])
if __name__ == "__main__":
main()