Skip to content

Commit 36f13b8

Browse files
605 ActionLoop Exception (#606)
1 parent 8575795 commit 36f13b8

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

pykern/pkasyncio.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,30 @@ def __target(self):
200200
self._start()
201201
except Exception as e:
202202
pkdlog("error={} {} stack={}", e, self, pkdexc(simplify=True))
203+
try:
204+
self._handle_exception(e)
205+
except Exception as e:
206+
pkdlog(
207+
"_handle_exception error={} {} stack={}",
208+
e,
209+
self,
210+
pkdexc(simplify=True),
211+
)
203212
finally:
204213
self.destroy()
205214

215+
def _handle_exception(self, exc):
216+
"""Exception handler for `_start`.
217+
218+
`_handle_exception` is called when there's an exception in `_start`.
219+
220+
Subclasses may reimplement.
221+
222+
Args:
223+
exc (Exception): Captured Exception.
224+
"""
225+
pass
226+
206227

207228
class Loop:
208229
"""HTTP Server loop"""

0 commit comments

Comments
 (0)