Update notebook

This commit is contained in:
William Fu-Hinthorn
2024-02-02 16:07:20 -08:00
parent 00a976ebb6
commit 3b64ed576b
4 changed files with 208 additions and 173 deletions
@@ -1,33 +0,0 @@
import asyncio
import logging
import nest_asyncio
logger = logging.getLogger(__name__)
def apply():
nest_asyncio.apply()
# shorthand for the class whose __del__ raises the exception
_BEL = asyncio.base_events.BaseEventLoop
_UWP = getattr(asyncio.unix_events, "_UnixWritePipeTransport", None)
_TAS = asyncio.tasks.Task
_original_del = _BEL.__del__
def _patched_del(self):
try:
# invoke the original method...
_original_del(self)
except Exception as e: # type: ignore
# ... but ignore any exceptions it might raise
# NOTE: horrible anti-pattern. Just using because
# jupyter notebooks don't play nice with asyncio
logger.debug(f"Exception in __del__ of {self}: {e}")
pass
# replace the original __del__ method
for op in (_BEL, _TAS, _UWP):
if op is not None:
op.__del__ = _patched_del
Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

File diff suppressed because one or more lines are too long