jackfrued / jackfrued/Python-100-Days
day14中的windows环境multiprocess调用Process没有效果
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 187k
- Forks
- 55.8k
- PR merge metrics
- No merged PRs in 30d
Description
from multiprocessing import Process
from os import getpid
from time import time, sleep
from random import randint
def download_task(filename):
print('启动进程,进程号[%d]' % getpid())
print('开始下载%s...' % (filename))
time_to_download = randint(5,10)
sleep(time_to_download)
print('%s下载完成! 耗费了%d秒' % (filename, time_to_download))
def main():
start = time()
p1 = Process(target=download_task, args=('Python从入门到住院.pdf',))
p1.start()
p2 = Process(target=download_task, args=('Peking Hot.avi',))
p2.start()
p1.join()
p2.join()
end = time()
print('总共耗费了%.2f秒.' % (end - start))
if name == 'main':
main()
最后的输出只有: 总共耗费了0.15秒.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the multiprocessing example shown in the issue and check how it is being run on Windows, including the Process entry point and child-process output. Reproduce the reported result, then verify that both child processes print their progress and that the total time reflects concurrent five-to-ten-second tasks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100