Skip to content

os: implement os.nice #2935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2021
Merged

os: implement os.nice #2935

merged 1 commit into from
Aug 25, 2021

Conversation

zetwhite
Copy link
Contributor

@zetwhite zetwhite commented Aug 22, 2021

this implements os.nice (which linked to a unix system call, changing process priority) function.

with this commit, rustpyhton works as below.

>>>>> import os
>>>>> os.nice(0)
0
>>>>> os.nice(-1)
-1
>>>>> os.nice(-10)
-11
>>>>> os.nice(10)
-1
>>>>> os.nice(20)
19
>>>>> os.nice(20)
19
>>>>> os.nice(-20)
-1
>>>>> os.nice(-12)
-13
>>>>> os.nice(-100)
-20

@zetwhite zetwhite force-pushed the master branch 3 times, most recently from 6ce9633 to 436dece Compare August 22, 2021 09:57
Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

nice function is defined in posix module rather than os itself. Please move this funciton to posix module in the same file. (Search for mod posix {)
Then os module will import it from posix automatically. Becasue posix module is defined only for unix, you don't need to add #[cfg(unix)] then.

@zetwhite zetwhite force-pushed the master branch 2 times, most recently from 264079b to 2f08be5 Compare August 24, 2021 17:31
@zetwhite
Copy link
Contributor Author

Thank you for your kind comment!
I changed as you mentioned. please check it out.

@youknowone youknowone merged commit d7bacf0 into RustPython:main Aug 25, 2021
@youknowone youknowone added the z-ca-2021 Tag to track contrubution-academy 2021 label Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
z-ca-2021 Tag to track contrubution-academy 2021
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants