Skip to content

Conversation

@likewei92
Copy link
Contributor

According to python docs, wait3 and wait4 returns a resource usages struct the same as resources.getrusage. The typing for that struct already exists, using it here.
https://docs.python.org/3/library/os.html#os.wait3

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@Akuli Akuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! These return struct_rusage as expected on my system:

>>> import os
>>> if (child_pid := os.fork()) == 0: os.execvp("sleep", ["sleep", "20"])
... 
>>> os.wait3(0)
(8771, 0, resource.struct_rusage(ru_utime=0.0029389999999999998, ru_stime=0.0, ru_maxrss=9652, ru_ixrss=0, ru_idrss=0, ru_isrss=0, ru_minflt=291, ru_majflt=0, ru_nswap=0, ru_inblock=0, ru_oublock=0, ru_msgsnd=0, ru_msgrcv=0, ru_nsignals=0, ru_nvcsw=2, ru_nivcsw=0))
>>> if (child_pid := os.fork()) == 0: os.execvp("sleep", ["sleep", "20"])
... 
>>> os.wait4(child_pid, 0)
(8787, 0, resource.struct_rusage(ru_utime=0.0, ru_stime=0.002195, ru_maxrss=9840, ru_ixrss=0, ru_idrss=0, ru_isrss=0, ru_minflt=294, ru_majflt=0, ru_nswap=0, ru_inblock=0, ru_oublock=0, ru_msgsnd=0, ru_msgrcv=0, ru_nsignals=0, ru_nvcsw=2, ru_nivcsw=1))

@Akuli Akuli merged commit 3edfd90 into python:main Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants