Skip to content

Commit e960a3e

Browse files
committed
add set_flags func.
1 parent ea3afcf commit e960a3e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib_utility.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ def merge_hash(a, b):
111111

112112
return result
113113

114+
import fcntl as _fcntl
115+
116+
def _set_flags(fd, flags):
117+
try:
118+
flag = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0)
119+
except IOError:
120+
pass
121+
else:
122+
# flags read successfully, modify
123+
flag |= flags
124+
_fcntl.fcntl(fd, _fcntl.F_SETFD, flags)
125+
114126
if __name__ == "__main__":
115127
print newer("utility.py", "util.py")
116128

0 commit comments

Comments
 (0)