Skip to content

Instantly share code, notes, and snippets.

@tonyg
Created June 16, 2021 06:46
Show Gist options
  • Save tonyg/a02a582e5300d61264211710dc68926f to your computer and use it in GitHub Desktop.
Save tonyg/a02a582e5300d61264211710dc68926f to your computer and use it in GitHub Desktop.
Printing out everything managed by a custodian
(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