REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.37 KB
Close
/lib/python3.6/site-packages/rhn/nonblocking.py
Text
Base64
# # # import select import fcntl import os class NonBlockingFile: def __init__(self, fd): # Keep a copy of the file descriptor self.fd = fd fcntl.fcntl(self.fd.fileno(), fcntl.F_SETFL, os.O_NDELAY) # Set the callback-related stuff self.read_fd_set = [] self.write_fd_set = [] self.exc_fd_set = [] self.user_data = None self.callback = None def set_callback(self, read_fd_set, write_fd_set, exc_fd_set, user_data, callback): self.read_fd_set = read_fd_set # Make the objects non-blocking for f in self.read_fd_set: fcntl.fcntl(f.fileno(), fcntl.F_SETFL, os.O_NDELAY) self.write_fd_set = write_fd_set self.exc_fd_set = exc_fd_set self.user_data = user_data self.callback = callback def read(self, amt=0): while 1: status_changed = 0 readfds = self.read_fd_set + [self.fd] writefds = self.write_fd_set excfds = self.exc_fd_set print("Calling select", readfds) readfds, writefds, excfds = select.select(readfds, writefds, excfds) print("Select returned", readfds, writefds, excfds) if self.fd in readfds: # Our own file descriptor has changed status # Mark this, but also try to call the callback with the rest # of the file descriptors that changed status status_changed = 1 readfds.remove(self.fd) if self.callback and (readfds or writefds or excfds): self.callback(readfds, writefds, excfds, self.user_data) if status_changed: break print("Returning") return self.fd.read(amt) def write(self, data): return self.fd.write(data) def __getattr__(self, name): return getattr(self.fd, name) def callback(r, w, e, user_data): print("Callback called", r, w, e) print(r[0].read()) if __name__ == '__main__': import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("localhost", 5555)) f = s.makefile() ss = NonBlockingFile(f) s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s2.connect(("localhost", 5556)) f = s2.makefile() ss.set_callback([f], [], [], None, callback) xx = ss.read() print(len(xx))
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 2 × Files: 11
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
actions
DIR
-
drwxr-xr-x
2025-07-18 07:00:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__pycache__
DIR
-
drwxr-xr-x
2024-10-12 07:01:54
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
connections.py
9.48 KB
lrw-r--r--
2024-09-17 10:10:54
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
i18n.py
1.73 KB
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
nonblocking.py
2.37 KB
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rhnLockfile.py
3.35 KB
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
rpclib.py
23.73 KB
lrw-r--r--
2024-09-17 10:10:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
SmartIO.py
2.11 KB
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
SSL.py
10.79 KB
lrw-r--r--
2024-09-17 10:10:54
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
tb.py
836 B
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
transports.py
31.23 KB
lrw-r--r--
2024-09-17 10:10:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
UserDictCase.py
2.96 KB
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
132 B
lrw-r--r--
2018-02-19 08:18:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).