This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add os.get_blocking() and os.set_blocking() functions
Type: enhancement Stage:
Components: Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: akira, neologix, pitrou, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2014-07-23 21:30 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
os_blocking.patch vstinner, 2014-07-23 21:30 review
os_blocking-2.patch vstinner, 2014-07-23 21:39 review
Messages (9)
msg223782 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-07-23 21:30
Antoine suggested me to add these functions in the issue #22042.

Here is a patch to implement these functions and use them in various places.
msg223784 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-07-23 21:39
Oops, test_asyncio was failing. Fixed patched.
msg224131 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-07-27 13:50
Can someone please review my patch?
msg224162 - (view) Author: Akira Li (akira) * Date: 2014-07-28 11:07
Maybe is_something() is a better name than get_something()
if something is a boolean?
msg224165 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-07-28 12:39
> Maybe is_something() is a better name than get_something()
> if something is a boolean?

os and socket modules already use getxxx() / setxxx() names:

- os.get_inheritable() / os.set_inheritable()
- os.getuid() / os.setuid()
- os.getgroups() / os.setgroups()
- os.getxattr() os.setxattr()
- socket.gettimeout() / socket.settimeout()
- socket.get_inheritable() / socket.set_inheritable()
- etc.

There is only one "is" function: os.isatty(), but it does not have a "os.settty" method.
msg224170 - (view) Author: Akira Li (akira) * Date: 2014-07-28 14:52
> os and socket modules already use getxxx() / setxxx() names:
>
> - os.get_inheritable() / os.set_inheritable()
> - os.getuid() / os.setuid()
> - os.getgroups() / os.setgroups()
> - os.getxattr() os.setxattr()
> - socket.gettimeout() / socket.settimeout()
> - socket.get_inheritable() / socket.set_inheritable()
> - etc.

egid, euid, gid, groups, pgid, pgrp, priority, resgid, sid, uid, xatrr,
hostname, timeout, sockopt are not boolean. Though
get_inheritable() spoils the pot.

Compare:

  if os.get_blocking(fd): # is it a bug? Does it return some mode bits?
     # Do I need stat.IS_BLK(os.get_blocking(fd)) here instead?

And:

  if os.is_blocking(fd):
     # it is clear that fd is blocking

There could be an argument that get_inheritable should be renamed to
is_inheritable instead.
msg224171 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2014-07-28 16:54
I agree with Akira, although it's probably too late now to rename.
msg224184 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-07-28 20:30
Guido van Rossum told me that he's ok for "get": "I'd go with get, since that seems the tradition in the os module."
msg224247 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-07-29 20:38
New changeset 8f0b8ddbb66b by Victor Stinner in branch 'default':
Issue #22054: Add os.get_blocking() and os.set_blocking() functions to get and
http://hg.python.org/cpython/rev/8f0b8ddbb66b
History
Date User Action Args
2022-04-11 14:58:06adminsetgithub: 66253
2014-07-29 20:39:06vstinnersetstatus: open -> closed
resolution: fixed
2014-07-29 20:38:50python-devsetnosy: + python-dev
messages: + msg224247
2014-07-28 20:30:51vstinnersetmessages: + msg224184
2014-07-28 16:54:18neologixsetmessages: + msg224171
2014-07-28 14:52:46akirasetmessages: + msg224170
2014-07-28 12:39:20vstinnersetmessages: + msg224165
2014-07-28 11:07:35akirasetnosy: + akira
messages: + msg224162
2014-07-27 13:50:38vstinnersetmessages: + msg224131
2014-07-23 21:39:07vstinnersetfiles: + os_blocking-2.patch

messages: + msg223784
2014-07-23 21:30:14vstinnercreate