Add-on - open_mainfile() always leads to segmentation fault I've been struggling for making bpy.ops.wm.open_mainfile(filepath=PATH) work properly within an Add-on.
No matter what I do and where I put it, I always get:
segmentation fault  /Applications/Blender.app/Contents/MacOS/Blender

For now I'm testing it like this:

I'm adding a handler to detect when a file is opened
 bpy.app.handlers.load_post.append(load_post)


In this handler I'm setting a Timer to open a new file after 5 seconds
 def load_post(ok,no):
     global t
     t = Timer(5.0, openNew)
     t.start()


Then the openNew is defined like this
 def hello():
     t.cancel()
     bpy.ops.wm.open_mainfile(filepath=&quot;/correct/file/path/test.blend&quot;)



Why am I testing it like this? Because I'm trying to make an Add-on that opens a file, do something in this file, saves it, and then open the next file. Timer is a simulation of this.
Here is the crash log.
# backtrace
0   Blender                             0x0000000107437387 BLI_system_backtrace + 55
1   Blender                             0x0000000100fe8ef8 sig_handle_crash + 392
2   libsystem_platform.dylib            0x00007fff693415fd _sigtramp + 29
3   ???                                 0x0000000000000000 0x0 + 0
4   Blender                             0x0000000101663bb7 Scene_statistics_call + 39
5   Blender                             0x0000000101556fc2 RNA_function_call + 18
6   Blender                             0x00000001016e67a4 pyrna_func_call + 2004
7   Blender                             0x0000000105e89faf _PyObject_FastCallKeywords + 575
8   Blender                             0x0000000105f5f485 call_function + 773
9   Blender                             0x0000000105f5beee _PyEval_EvalFrameDefault + 27262
10  Blender                             0x0000000105e8a66d function_code_fastcall + 237
11  Blender                             0x00000001016e8221 bpy_class_call + 961
12  Blender                             0x00000001016973e3 header_draw + 115
13  Blender                             0x00000001017000a4 ED_region_header_layout + 404
14  Blender                             0x000000010132b2ff wm_draw_update + 1631
15  Blender                             0x0000000101329040 WM_main + 48
16  Blender                             0x0000000100fe5621 main + 929
17  libdyld.dylib                       0x00007fff69148cc9 start + 1

P.S. If I run this exact command on the Scripting area of the Blend file, and not from an Add-on, it runs like a charm.
Threading is not supported in Blender.
So I changed it to:
import bpy
def test():
    bpy.ops.wm.open_mainfile(filepath=bpy.data.filepath)
    return -1.0
bpy.app.timers.register(test)

But this also wasn't working. Version 2.91.0 Alpha has already a commit fixing this bug.
You can check committed notes here: https://developer.blender.org/T80028