Created
June 16, 2021 06:46
-
-
Save tonyg/a02a582e5300d61264211710dc68926f to your computer and use it in GitHub Desktop.
Printing out everything managed by a custodian
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
(on (message (dump-debug-info)) | |
(local-require racket/exn) | |
(local-require racket/tcp) | |
(printf "------------------------------------------------------------\n") | |
(for [(index (in-naturals)) | |
(item (custodian-managed-list (current-custodian) outer-custodian))] | |
(printf "\nItem ~a.\n~v\n" index item) | |
(cond | |
[(thread? item) | |
(printf "Thread: (dead? ~v)\n~a" | |
(thread-dead? item) | |
(exn->string (exn "Stack snapshot:" (continuation-marks item))))] | |
[(tcp-port? item) | |
(printf "TCP port: (addresses ~v)\n" | |
(call-with-values (lambda () (tcp-addresses item #t)) list))] | |
[else (void)]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment