This repository has been archived by the owner on May 9, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import inspect | ||
|
||
# work in progress: | ||
|
||
# when a task is ultimately waiting on gather(), _done_callback is visible. | ||
|
||
|
||
def decipher_done_callback(done_callback): | ||
closure = inspect.getclosurevars(done_callback).nonlocals | ||
state = f"progress: {closure['nfinished']}/{closure['nfuts']}" | ||
future = closure["outer"] | ||
print(future, state) | ||
children = closure["children"] | ||
for child in children: | ||
if child.done(): | ||
# resolved, exception, cancelled | ||
if child.cancelled(): | ||
print(child, "cancelled") | ||
elif child.exception(): | ||
print(child, child.exception()) | ||
else: | ||
print(child, child.result()) | ||
else: | ||
print(child, "pending") | ||
|
||
|
||
def task_callback(t): | ||
# FIXME: there may be several; py 3.8 vs py 3.7 | ||
return t._callbacks[0][0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters