Minor fix to timeout test and added timed_out field
This commit is contained in:
parent
351a212ccd
commit
4d50130d53
|
@ -29,6 +29,8 @@ class TaskScope:
|
|||
self.attempted_cancel: bool = False
|
||||
# Have we been cancelled?
|
||||
self.cancelled: bool = False
|
||||
# Have we timed out?
|
||||
self.timed_out: bool = False
|
||||
# Can we be indirectly cancelled? Note that this
|
||||
# does not affect explicit cancellations via the
|
||||
# cancel() method
|
||||
|
|
|
@ -249,6 +249,7 @@ class FIFOKernel(BaseKernel):
|
|||
def check_scopes(self):
|
||||
for scope in self.pool.scope.children:
|
||||
if scope.get_actual_timeout() <= self.clock.current_time():
|
||||
scope.timed_out = True
|
||||
if scope.silent:
|
||||
self.cancel_scope(scope)
|
||||
self.reschedule(scope.owner)
|
||||
|
@ -447,6 +448,8 @@ class FIFOKernel(BaseKernel):
|
|||
# cancel() for a scope which it doesn't own, which
|
||||
# is an entirely reasonable thing to do
|
||||
self.cancel_task(scope.owner)
|
||||
if scope.done():
|
||||
scope.cancelled = True
|
||||
|
||||
def init_pool(self, pool: TaskPool):
|
||||
pool.outer = self.current_pool
|
||||
|
|
|
@ -8,7 +8,7 @@ async def test_silent(i, j):
|
|||
print(f"[test] Sleeping for {j} seconds")
|
||||
await structio.sleep(j)
|
||||
print(
|
||||
f"[test] Finished in {structio.clock() - k:.2f} seconds (timed out: {scope.cancelled})"
|
||||
f"[test] Finished in {structio.clock() - k:.2f} seconds (timed out: {scope.timed_out})"
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue