Reformat with black

This commit is contained in:
Mattia Giambirtone 2024-02-23 13:11:14 +01:00
parent fe8c319170
commit 279a2a3d3f
Signed by: nocturn9x
GPG Key ID: 8270F9F467971E59
7 changed files with 25 additions and 8 deletions

View File

@ -6,7 +6,14 @@ from structio.core.managers.signals.sigint import SigIntManager
from structio.core.time.clock import DefaultClock
from structio.core.syscalls import sleep, suspend as _suspend
from structio.core.context import TaskPool, TaskScope
from structio.exceptions import Cancelled, TimedOut, ResourceClosed, ResourceBroken, ResourceBusy, WouldBlock
from structio.exceptions import (
Cancelled,
TimedOut,
ResourceClosed,
ResourceBroken,
ResourceBusy,
WouldBlock,
)
from structio.core import task
from structio.core.task import Task, TaskState
from structio.sync import (
@ -167,5 +174,5 @@ __all__ = [
"util",
"ResourceBusy",
"ResourceBroken",
"WouldBlock"
"WouldBlock",
]

View File

@ -260,7 +260,6 @@ class FIFOKernel(BaseKernel):
self.throw(scope.owner, error)
self.reschedule(scope.owner)
def wakeup(self):
while (
self.paused

View File

@ -51,4 +51,4 @@ class WouldBlock(StructIOException):
"""
Raised when a non-blocking operation
cannot be carried out immediately
"""
"""

View File

@ -80,7 +80,7 @@ class AsyncFile(AsyncResource):
async def readall(self):
chunks = []
maxread = 65536
sep = '' if hasattr(self._file, 'encoding') else b''
sep = "" if hasattr(self._file, "encoding") else b""
while True:
chunk = await self.read(maxread)
if not chunk:

View File

@ -7,6 +7,7 @@ import platform
import subprocess
from subprocess import CalledProcessError, CompletedProcess, DEVNULL, PIPE
from structio.io import FileStream
if platform.system() == "Windows":
# Windows doesn't really support non-blocking file
# descriptors (except sockets), so we just use threads

View File

@ -53,7 +53,9 @@ class Event:
"""
if self.is_set():
raise RuntimeError("this event has already been set: create a new Event object instead")
raise RuntimeError(
"this event has already been set: create a new Event object instead"
)
self._set = True
for waiter in self._tasks:
current_loop().reschedule(waiter)

View File

@ -202,7 +202,6 @@ async def _coroutine_request_handler(
coroutines: AsyncThreadQueue,
results: AsyncThreadQueue,
reader: "structio.socket.AsyncSocket",
):
"""
Runs coroutines on behalf of a thread spawned by structio and
@ -300,7 +299,16 @@ async def run_in_worker(
# Start the worker thread
threading.Thread(
target=_threaded_runner,
args=(sync_func, current_loop(), rq, rsq, terminate, wakeup, wakeup2, *args),
args=(
sync_func,
current_loop(),
rq,
rsq,
terminate,
wakeup,
wakeup2,
*args,
),
name=f"structio-worker-thread-{worker_id}",
# We start cancellable threads in daemonic mode so that
# the main thread doesn't get stuck waiting on them forever