From fef5537aa8c76ddefcdb6485640038379fe2b82e Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 13 Sep 2018 13:09:42 +0200 Subject: [PATCH] if our global callback does not have access to globals anymore, just return 0 gracefully --- python/src/deltachat/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/src/deltachat/__init__.py b/python/src/deltachat/__init__.py index 48ee40b5..255c6573 100644 --- a/python/src/deltachat/__init__.py +++ b/python/src/deltachat/__init__.py @@ -13,7 +13,13 @@ def py_dc_callback(ctx, evt, data1, data2): CFFI only allows us to set one global event handler, so this one looks up the correct event handler for the given context. """ - callback = _DC_CALLBACK_MAP.get(ctx, lambda *a: 0) + try: + callback = _DC_CALLBACK_MAP.get(ctx, lambda *a: 0) + except AttributeError: + # we are in a deep in GC-free/interpreter shutdown land + # nothing much better to do here than: + return 0 + # the following code relates to the deltachat/_build.py's helper # function which provides us signature info of an event call evt_name = get_dc_event_name(evt)