Server IP : 149.255.58.128 / Your IP : 216.73.216.113
System : Linux cloud516.thundercloud.uk 5.14.0-427.26.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 17 15:51:13 EDT 2024 x86_64
PHP Version : 8.2.28
Disable Function : allow_url_include, apache_child_terminate, apache_setenv, exec, passthru, pcntl_exec, posix_kill, posix_mkfifo, posix_getpwuid, posix_setpgid, posix_setsid, posix_setuid, posix_setgid, posix_seteuid, posix_setegid, posix_uname, proc_close, proc_get_status, proc_open, proc_terminate, shell_exec, show_source, system
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Upload Files :
Command :
Current File : /usr/lib/python3.9/site-packages/rhn//nonblocking.py
#
#
#
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))
Name |
Size |
Last Modified |
Owner / Group |
Permissions |
Options |
.. | -- | March 19 2025 22:42:16 | 0 / root | 0755 | |
__pycache__ | -- | October 13 2023 17:01:36 | 0 / root | 0755 | |
actions | -- | March 18 2025 22:42:18 | 0 / root | 0755 | |
| | | | | |
SSL.py | 10.794 KB | December 07 2022 13:15:22 | 0 / root | 0644 | |
SmartIO.py | 2.113 KB | February 19 2018 08:18:29 | 0 / root | 0644 | |
UserDictCase.py | 2.963 KB | February 19 2018 08:18:29 | 0 / root | 0644 | |
__init__.py | 0.129 KB | February 19 2018 08:18:29 | 0 / root | 0644 | |
connections.py | 9.484 KB | December 07 2022 13:15:22 | 0 / root | 0644 | |
i18n.py | 1.731 KB | February 19 2018 08:18:29 | 0 / root | 0644 | |
nonblocking.py | 2.37 KB | February 19 2018 08:18:29 | 0 / root | 0644 | |
rhnLockfile.py | 3.347 KB | February 19 2018 08:18:29 | 0 / root | 0644 | |
rpclib.py | 23.678 KB | December 07 2022 13:15:24 | 0 / root | 0644 | |
tb.py | 0.816 KB | February 19 2018 08:18:29 | 0 / root | 0644 | |
transports.py | 31.179 KB | December 07 2022 13:15:24 | 0 / root | 0644 | |