main commit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-16 16:30:25 +09:00
parent 91c7e04474
commit 537e7b363f
1146 changed files with 45926 additions and 77196 deletions

View File

@@ -103,35 +103,26 @@ def _get_job_writer(job):
return writer() # is a weakref
def _ensure_integral_fd(fd):
return fd if isinstance(fd, Integral) else fd.fileno()
if hasattr(select, 'poll'):
def _select_imp(readers=None, writers=None, err=None, timeout=0,
poll=select.poll, POLLIN=select.POLLIN,
POLLOUT=select.POLLOUT, POLLERR=select.POLLERR):
poller = poll()
register = poller.register
fd_to_mask = {}
if readers:
for fd in map(_ensure_integral_fd, readers):
fd_to_mask[fd] = fd_to_mask.get(fd, 0) | POLLIN
[register(fd, POLLIN) for fd in readers]
if writers:
for fd in map(_ensure_integral_fd, writers):
fd_to_mask[fd] = fd_to_mask.get(fd, 0) | POLLOUT
[register(fd, POLLOUT) for fd in writers]
if err:
for fd in map(_ensure_integral_fd, err):
fd_to_mask[fd] = fd_to_mask.get(fd, 0) | POLLERR
for fd, event_mask in fd_to_mask.items():
register(fd, event_mask)
[register(fd, POLLERR) for fd in err]
R, W = set(), set()
timeout = 0 if timeout and timeout < 0 else round(timeout * 1e3)
events = poller.poll(timeout)
for fd, event in events:
if not isinstance(fd, Integral):
fd = fd.fileno()
if event & POLLIN:
R.add(fd)
if event & POLLOUT:
@@ -203,7 +194,7 @@ def iterate_file_descriptors_safely(fds_iter, source_data,
or possibly other reasons, so safely manage our lists of FDs.
:param fds_iter: the file descriptors to iterate and apply hub_method
:param source_data: data source to remove FD if it renders OSError
:param hub_method: the method to call with each fd and kwargs
:param hub_method: the method to call with with each fd and kwargs
:*args to pass through to the hub_method;
with a special syntax string '*fd*' represents a substitution
for the current fd object in the iteration (for some callers).
@@ -781,7 +772,7 @@ class AsynPool(_pool.Pool):
None, WRITE | ERR, consolidate=True)
else:
iterate_file_descriptors_safely(
inactive, all_inqueues, hub.remove_writer)
inactive, all_inqueues, hub_remove)
self.on_poll_start = on_poll_start
def on_inqueue_close(fd, proc):
@@ -827,7 +818,7 @@ class AsynPool(_pool.Pool):
# worker is already busy with another task
continue
if ready_fd not in all_inqueues:
hub.remove_writer(ready_fd)
hub_remove(ready_fd)
continue
try:
job = pop_message()
@@ -838,7 +829,7 @@ class AsynPool(_pool.Pool):
# this may create a spinloop where the event loop
# always wakes up.
for inqfd in diff(active_writes):
hub.remove_writer(inqfd)
hub_remove(inqfd)
break
else:
@@ -936,7 +927,7 @@ class AsynPool(_pool.Pool):
else:
errors = 0
finally:
hub.remove_writer(fd)
hub_remove(fd)
write_stats[proc.index] += 1
# message written, so this fd is now available
active_writes.discard(fd)