Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indeterminate live_server segfaults on macos (workaround: threading.Thread) #103

Open
abathur opened this issue Dec 30, 2019 · 0 comments
Open
Labels
stale This issue has not seen activity for a while

Comments

@abathur
Copy link

abathur commented Dec 30, 2019

Not sure this is short-run actionable, and I don't think it's actually a pytest-flask bug. If others encounter this it may still make sense to add something like the workaround I identified as an optional run mode or automatic fallback. Opening an issue in case it helps others or attracts more information/reports. The lack of similar reports makes me suspect this might come down to the OS or specific dependency versions--but I haven't had time to fiddle with them.

We had some trouble this fall with flaky test runs using live_server and selenium for end-to-end tests. I'll describe everything I can recall in case it helps someone find the issue; scroll to the end for the workaround. :)


Initial encounter/debug

The issue initially manifested as inconsistent test/fixture failures at the first location in a test that depended on finding/interacting with anything specific loaded (because the server never started and the browser has a blank page loaded). When I first encountered this, the test exception/assertion errors were all I got.

I eventually figured out that live_server._process could silently fail to start during setup. You can detect this with something like:

live_server.start()
if not live_server._process.is_alive():
   ...

While most of my test runs fail (running 2 parameterized tests 8x each), there's usually only one failure across the run. It often (but not always) fails on the same test. Any remaining tests usually run fine. Playing around for a bit (different numbers of tests, turning each test into a simple pass, renaming them to force different orders) made me think that where it breaks is somewhat correlated with how much work the tests make the server do.

Stepping through the code isolated the problem to when app.run(host=host, port=port, use_reloader=False, threaded=True) is called inside the worker/target function passed to multiprocessing.Process. At the time, I had trouble introspecting the child process (see the paragraph), but I did notice the crash produces OS crash reports. Here's an example:

segfault crash report
Process:               python3.6 [92689]
Path:                  /nix/*/python3.6
Identifier:            python3.6
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        python3.6 [92491]
Responsible:           python3.6 [92689]
User ID:               501

Date/Time:             2019-12-30 11:58:18.934 -0600
OS Version:            Mac OS X 10.14.6 (18G103)
Report Version:        12
Bridge OS Version:     3.6 (16P6571)
Anonymous UUID:        73B82B43-D894-E9FF-58D2-C4D60BD5AEFB

Sleep/Wake UUID:       6A0E1A0F-A8D2-4968-9C72-E38508FDB072

Time Awake Since Boot: 550000 seconds
Time Since Wake:       8300 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x000000010b060a3a
Exception Note:        EXC_CORPSE_NOTIFY

VM Regions Near 0x10b060a3a:
    VM_ALLOCATE            000000010abe0000-000000010b060000 [ 4608K] rw-/rwx SM=COW  
--> 
    VM_ALLOCATE            000000010b0a0000-000000010b2a0000 [ 2048K] rw-/rwx SM=COW  

Application Specific Information:
crashed on child side of fork pre-exec

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff6ac462c6 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff6ad01bf1 pthread_kill + 284
2   libsystem_c.dylib             	0x00007fff6ab63d8a raise + 26
3   libsystem_platform.dylib      	0x00007fff6acf6b5d _sigtramp + 29
4   ???                           	0x00007fffa13ad000 0 + 140735898374144
5   libsystem_trace.dylib         	0x00007fff6ad1a13d os_log_type_enabled + 627
6   libsystem_info.dylib          	0x00007fff6ac2c709 si_destination_compare_statistics + 1993
7   libsystem_info.dylib          	0x00007fff6ac2b1a5 si_destination_compare_internal + 661
8   libsystem_info.dylib          	0x00007fff6ac2ad3f si_destination_compare + 559
9   libsystem_info.dylib          	0x00007fff6ac096df _gai_addr_sort + 111
10  libsystem_c.dylib             	0x00007fff6abb3e5b _isort + 193
11  libsystem_c.dylib             	0x00007fff6abb3d88 _qsort + 2125
12  libsystem_info.dylib          	0x00007fff6ac00f2d _gai_sort_list + 781
13  libsystem_info.dylib          	0x00007fff6abff885 si_addrinfo + 2021
14  libsystem_info.dylib          	0x00007fff6abfef77 _getaddrinfo_internal + 231
15  libsystem_info.dylib          	0x00007fff6abfee7d getaddrinfo + 61
16  _socket.cpython-36m-darwin.so 	0x0000000107e4649e setipaddr + 494
17  _socket.cpython-36m-darwin.so 	0x0000000107e45d3b getsockaddrarg + 539
18  _socket.cpython-36m-darwin.so 	0x0000000107e43044 sock_bind + 52
19  libpython3.6m.dylib           	0x00000001064ab852 _PyCFunction_FastCallDict + 610
20  libpython3.6m.dylib           	0x000000010653f57a call_function + 602
21  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
22  libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
23  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
24  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
25  libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
26  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
27  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
28  libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
29  libpython3.6m.dylib           	0x000000010654097b fast_function + 411
30  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
31  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
32  libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
33  libpython3.6m.dylib           	0x0000000106540d6f _PyFunction_FastCallDict + 607
34  libpython3.6m.dylib           	0x0000000106459aa6 _PyObject_FastCallDict + 182
35  libpython3.6m.dylib           	0x0000000106459c3c _PyObject_Call_Prepend + 156
36  libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
37  libpython3.6m.dylib           	0x00000001064c548f slot_tp_init + 159
38  libpython3.6m.dylib           	0x00000001064c1224 type_call + 292
39  libpython3.6m.dylib           	0x0000000106459b31 _PyObject_FastCallDict + 321
40  libpython3.6m.dylib           	0x0000000106459f55 _PyObject_FastCallKeywords + 197
41  libpython3.6m.dylib           	0x000000010653f4f2 call_function + 466
42  libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
43  libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
44  libpython3.6m.dylib           	0x000000010654097b fast_function + 411
45  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
46  libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
47  libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
48  libpython3.6m.dylib           	0x000000010654097b fast_function + 411
49  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
50  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
51  libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
52  libpython3.6m.dylib           	0x0000000106535b37 PyEval_EvalCodeEx + 55
53  libpython3.6m.dylib           	0x0000000106487a0f function_call + 399
54  libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
55  libpython3.6m.dylib           	0x000000010653c5b0 _PyEval_EvalFrameDefault + 27184
56  libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
57  libpython3.6m.dylib           	0x000000010654097b fast_function + 411
58  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
59  libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
60  libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
61  libpython3.6m.dylib           	0x0000000106535b37 PyEval_EvalCodeEx + 55
62  libpython3.6m.dylib           	0x0000000106487a0f function_call + 399
63  libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
64  libpython3.6m.dylib           	0x000000010653c5b0 _PyEval_EvalFrameDefault + 27184
65  libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
66  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
67  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
68  libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
69  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
70  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
71  libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
72  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
73  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
74  libpython3.6m.dylib           	0x0000000106540f0b _PyFunction_FastCallDict + 1019
75  libpython3.6m.dylib           	0x0000000106459aa6 _PyObject_FastCallDict + 182
76  libpython3.6m.dylib           	0x0000000106459c3c _PyObject_Call_Prepend + 156
77  libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
78  libpython3.6m.dylib           	0x00000001064c548f slot_tp_init + 159
79  libpython3.6m.dylib           	0x00000001064c1224 type_call + 292
80  libpython3.6m.dylib           	0x0000000106459b31 _PyObject_FastCallDict + 321
81  libpython3.6m.dylib           	0x000000010653f4f2 call_function + 466
82  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
83  libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
84  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
85  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
86  libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
87  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
88  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
89  libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
90  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
91  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
92  libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
93  libpython3.6m.dylib           	0x000000010653f549 call_function + 553
94  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
95  libpython3.6m.dylib           	0x000000010647e2dc gen_send_ex + 252
96  libpython3.6m.dylib           	0x0000000106533bae builtin_next + 110
97  libpython3.6m.dylib           	0x00000001064ab6a4 _PyCFunction_FastCallDict + 180
98  libpython3.6m.dylib           	0x000000010653f57a call_function + 602
99  libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
100 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
101 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
102 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
103 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
104 libpython3.6m.dylib           	0x0000000106535b37 PyEval_EvalCodeEx + 55
105 libpython3.6m.dylib           	0x0000000106487a0f function_call + 399
106 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
107 libpython3.6m.dylib           	0x000000010653c5b0 _PyEval_EvalFrameDefault + 27184
108 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
109 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
110 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
111 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
112 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
113 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
114 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
115 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
116 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
117 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
118 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
119 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
120 libpython3.6m.dylib           	0x0000000106540d6f _PyFunction_FastCallDict + 607
121 libpython3.6m.dylib           	0x0000000106459aa6 _PyObject_FastCallDict + 182
122 libpython3.6m.dylib           	0x0000000106459c3c _PyObject_Call_Prepend + 156
123 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
124 libpython3.6m.dylib           	0x00000001064c4499 slot_tp_call + 153
125 libpython3.6m.dylib           	0x0000000106459b31 _PyObject_FastCallDict + 321
126 libpython3.6m.dylib           	0x0000000106459f55 _PyObject_FastCallKeywords + 197
127 libpython3.6m.dylib           	0x000000010653f4f2 call_function + 466
128 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
129 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
130 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
131 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
132 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
133 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
134 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
135 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
136 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
137 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
138 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
139 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
140 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
141 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
142 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
143 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
144 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
145 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
146 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
147 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
148 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
149 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
150 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
151 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
152 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
153 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
154 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
155 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
156 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
157 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
158 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
159 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
160 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
161 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
162 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
163 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
164 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
165 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
166 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
167 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
168 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
169 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
170 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
171 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
172 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
173 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
174 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
175 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
176 libpython3.6m.dylib           	0x0000000106535b37 PyEval_EvalCodeEx + 55
177 libpython3.6m.dylib           	0x0000000106487a0f function_call + 399
178 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
179 libpython3.6m.dylib           	0x000000010653c5b0 _PyEval_EvalFrameDefault + 27184
180 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
181 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
182 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
183 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
184 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
185 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
186 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
187 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
188 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
189 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
190 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
191 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
192 libpython3.6m.dylib           	0x0000000106540d6f _PyFunction_FastCallDict + 607
193 libpython3.6m.dylib           	0x0000000106459aa6 _PyObject_FastCallDict + 182
194 libpython3.6m.dylib           	0x0000000106459c3c _PyObject_Call_Prepend + 156
195 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
196 libpython3.6m.dylib           	0x00000001064c4499 slot_tp_call + 153
197 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
198 libpython3.6m.dylib           	0x000000010653c5b0 _PyEval_EvalFrameDefault + 27184
199 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
200 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
201 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
202 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
203 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
204 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
205 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
206 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
207 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
208 libpython3.6m.dylib           	0x0000000106535b37 PyEval_EvalCodeEx + 55
209 libpython3.6m.dylib           	0x0000000106487a0f function_call + 399
210 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
211 libpython3.6m.dylib           	0x000000010653c5b0 _PyEval_EvalFrameDefault + 27184
212 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
213 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
214 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
215 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
216 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
217 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
218 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
219 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
220 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
221 libpython3.6m.dylib           	0x0000000106535b37 PyEval_EvalCodeEx + 55
222 libpython3.6m.dylib           	0x0000000106487a0f function_call + 399
223 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
224 libpython3.6m.dylib           	0x000000010653c5b0 _PyEval_EvalFrameDefault + 27184
225 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
226 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
227 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
228 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
229 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
230 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
231 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
232 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
233 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
234 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
235 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
236 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
237 libpython3.6m.dylib           	0x0000000106540d6f _PyFunction_FastCallDict + 607
238 libpython3.6m.dylib           	0x0000000106459aa6 _PyObject_FastCallDict + 182
239 libpython3.6m.dylib           	0x0000000106459c3c _PyObject_Call_Prepend + 156
240 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
241 libpython3.6m.dylib           	0x00000001064c4499 slot_tp_call + 153
242 libpython3.6m.dylib           	0x0000000106459b31 _PyObject_FastCallDict + 321
243 libpython3.6m.dylib           	0x0000000106459f55 _PyObject_FastCallKeywords + 197
244 libpython3.6m.dylib           	0x000000010653f4f2 call_function + 466
245 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
246 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
247 libpython3.6m.dylib           	0x0000000106535b37 PyEval_EvalCodeEx + 55
248 libpython3.6m.dylib           	0x0000000106487a0f function_call + 399
249 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
250 libpython3.6m.dylib           	0x000000010653c5b0 _PyEval_EvalFrameDefault + 27184
251 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
252 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
253 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
254 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
255 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
256 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
257 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
258 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
259 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
260 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
261 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
262 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
263 libpython3.6m.dylib           	0x0000000106540d6f _PyFunction_FastCallDict + 607
264 libpython3.6m.dylib           	0x0000000106459aa6 _PyObject_FastCallDict + 182
265 libpython3.6m.dylib           	0x0000000106459c3c _PyObject_Call_Prepend + 156
266 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
267 libpython3.6m.dylib           	0x00000001064c4499 slot_tp_call + 153
268 libpython3.6m.dylib           	0x0000000106459b31 _PyObject_FastCallDict + 321
269 libpython3.6m.dylib           	0x0000000106459f55 _PyObject_FastCallKeywords + 197
270 libpython3.6m.dylib           	0x000000010653f4f2 call_function + 466
271 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
272 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
273 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
274 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
275 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
276 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
277 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
278 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
279 libpython3.6m.dylib           	0x0000000106535b37 PyEval_EvalCodeEx + 55
280 libpython3.6m.dylib           	0x0000000106487a0f function_call + 399
281 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
282 libpython3.6m.dylib           	0x000000010653c5b0 _PyEval_EvalFrameDefault + 27184
283 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
284 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
285 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
286 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
287 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
288 libpython3.6m.dylib           	0x000000010654097b fast_function + 411
289 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
290 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
291 libpython3.6m.dylib           	0x0000000106540a19 fast_function + 569
292 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
293 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
294 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
295 libpython3.6m.dylib           	0x0000000106540d6f _PyFunction_FastCallDict + 607
296 libpython3.6m.dylib           	0x0000000106459aa6 _PyObject_FastCallDict + 182
297 libpython3.6m.dylib           	0x0000000106459c3c _PyObject_Call_Prepend + 156
298 libpython3.6m.dylib           	0x00000001064598e5 PyObject_Call + 101
299 libpython3.6m.dylib           	0x00000001064c4499 slot_tp_call + 153
300 libpython3.6m.dylib           	0x0000000106459b31 _PyObject_FastCallDict + 321
301 libpython3.6m.dylib           	0x0000000106459f55 _PyObject_FastCallKeywords + 197
302 libpython3.6m.dylib           	0x000000010653f4f2 call_function + 466
303 libpython3.6m.dylib           	0x000000010653c438 _PyEval_EvalFrameDefault + 26808
304 libpython3.6m.dylib           	0x0000000106540ad9 fast_function + 761
305 libpython3.6m.dylib           	0x000000010653f549 call_function + 553
306 libpython3.6m.dylib           	0x000000010653c3a5 _PyEval_EvalFrameDefault + 26661
307 libpython3.6m.dylib           	0x0000000106540163 _PyEval_EvalCodeWithName + 2883
308 libpython3.6m.dylib           	0x0000000106535af0 PyEval_EvalCode + 48
309 libpython3.6m.dylib           	0x000000010657074e PyRun_FileExFlags + 174
310 libpython3.6m.dylib           	0x000000010656fc45 PyRun_SimpleFileExFlags + 277
311 libpython3.6m.dylib           	0x000000010658d80a Py_Main + 3866
312 python3.6                     	0x00000001061d9db8 main + 248
313 python3.6                     	0x00000001061d9cb4 start + 52

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000111f6f5c0  rcx: 0x00007ffee9a105b8  rdx: 0x0000000000000000
  rdi: 0x0000000000000203  rsi: 0x000000000000000b  rbp: 0x00007ffee9a105f0  rsp: 0x00007ffee9a105b8
   r8: 0x00007ffee9a10ab8   r9: 0x33bb6fc8d10fca0a  r10: 0x0000000111f6f66c  r11: 0x0000000000000287
  r12: 0x0000000000000203  r13: 0x0000000000000000  r14: 0x000000000000000b  r15: 0x000000000000002d
  rip: 0x00007fff6ac462c6  rfl: 0x0000000000000286  cr2: 0x0000000107fbac98
  
Logical CPU:     0
Error Code:      0x02000148
Trap Number:     133


Binary Images:
       0x1061d9000 -        0x1061d9ff7 +python3.6 (???) <35FF5575-D6AC-3DA6-B015-B42B69210AF7> /nix/*/python3.6
       0x1061de000 -        0x106362fff +CoreFoundation (0) <16A969D9-5137-3572-8A2E-4AD27F8E2A69> /nix/*/CoreFoundation.framework/Versions/A/CoreFoundation
       0x10644b000 -        0x10665aff7 +libpython3.6m.dylib (3.6) <78A76B4A-DDDF-3426-96F3-9E4708F9FA45> /nix/*/libpython3.6m.dylib
       0x10672f000 -        0x10672ffff +libSystem.B.dylib (1226.10.1) <3F5A1DEE-940A-365E-BC6D-312CF83AFCF1> /nix/*/libSystem.B.dylib
       0x106731000 -        0x106731fff +grp.cpython-36m-darwin.so (???) <42F483BE-8B8F-3BA6-B313-FD618A10CB25> /nix/*/grp.cpython-36m-darwin.so
       0x106735000 -        0x10677cffb +libncursesw.6.dylib (0) <8E490522-234B-37BD-AAE0-B11B86076995> /nix/*/libncursesw.6.dylib
       0x106793000 -        0x106976ff7 +libicucore.A.dylib (0) <CDC07E9B-217D-3EE2-9530-E557530AF481> /nix/*/libicucore.A.dylib
       0x106a6a000 -        0x106ad7ff7 +libcurl.4.dylib (0) <436D2AC4-CCEF-31DB-BFA4-D524313B5AC2> /nix/*/libcurl.4.dylib
       0x106aec000 -        0x106aecfff +_bisect.cpython-36m-darwin.so (???) <CF29A42C-F9FA-3F9B-A726-B40D582E213C> /nix/*/_bisect.cpython-36m-darwin.so
       0x106aef000 -        0x106c2cfff +libxml2.2.dylib (0) <09A7EBAA-06E5-3E0D-9B25-E149FF192BED> /nix/*/libxml2.2.dylib
       0x106c5d000 -        0x106c5efff +_random.cpython-36m-darwin.so (???) <EC7A5AEB-7F0F-3A81-9DB4-3E29F14C2B8E> /nix/*/_random.cpython-36m-darwin.so
       0x106c61000 -        0x106cddff7 +libc++.1.0.dylib (0) <C7A1C95D-2474-362F-A9C2-027706C00B56> /nix/*/libc++.1.0.dylib
       0x106d39000 -        0x106d58ff7 +libc++abi.dylib (0) <D716EE50-B468-385A-BE45-5D06E86BA151> /nix/*/libc++abi.dylib
       0x106d72000 -        0x106d72fff +libsystem_c.dylib (0) <C32D34C8-BA8B-3354-8D1C-B3CFC3111E8A> /nix/*/libsystem_c.dylib
       0x106d8a000 -        0x106d8afff +libsystem_kernel.dylib (0) <0550AE42-4BC3-3B1E-8C21-3D3E5486B4FE> /nix/*/libsystem_kernel.dylib
       0x106da7000 -        0x106da7fff +libSystem_internal.dylib (0) <393A2DB2-3E05-3B6E-8B26-043AAF9EE831> /nix/*/libSystem_internal.dylib
       0x106da9000 -        0x106daaff7 +_heapq.cpython-36m-darwin.so (???) <BC86CB15-974D-3908-B3E0-DE5F21E1AC78> /nix/*/_heapq.cpython-36m-darwin.so
       0x106daf000 -        0x106dccff7 +libnghttp2.14.dylib (0) <CE050852-0C1D-3198-9646-C2EFC0E5406F> /nix/*/libnghttp2.14.dylib
       0x106dd8000 -        0x106e07ff3 +libssh2.1.dylib (0) <3B2E5A9F-543B-3180-9DF3-1227D5FDE2DE> /nix/*/libssh2.1.dylib
       0x106e13000 -        0x106e71ff3 +libssl.1.1.dylib (0) <549B9F8D-6C27-36D2-90F2-B2D23DFEDE44> /nix/*/libssl.1.1.dylib
       0x106e9a000 -        0x10707e37b +libcrypto.1.1.dylib (0) <A632411B-2AB0-3553-ABF5-8FBCBF7E7C53> /nix/*/libcrypto.1.1.dylib
       0x107110000 -        0x107141ff7 +libgssapi_krb5.2.2.dylib (0) <A80FEF43-EB00-3F5F-A001-FB48744215AD> /nix/*/libgssapi_krb5.2.2.dylib
       0x107152000 -        0x107176ff3 +libresolv.9.dylib (0) <99B3A32A-295C-3078-8543-498FED1EDBCE> /nix/*/libresolv.9.dylib
       0x10717f000 -        0x107180fff +_bz2.cpython-36m-darwin.so (???) <A36D9617-BCC4-3B15-8325-278718DB9531> /nix/*/_bz2.cpython-36m-darwin.so
       0x107185000 -        0x107199ff3 +libz.dylib (0) <948CB931-36A0-3203-AE70-A077681EEE58> /nix/*/libz.dylib
       0x10719f000 -        0x10722dff7 +libkrb5.3.3.dylib (0) <54778E86-DE3C-3480-9256-3F0ECD9A370D> /nix/*/libkrb5.3.3.dylib
       0x107265000 -        0x107266fff +fcntl.cpython-36m-darwin.so (???) <A6551221-5D1E-3B4F-BE7C-A30A00CE4EF3> /nix/*/fcntl.cpython-36m-darwin.so
       0x10726b000 -        0x107292fff +libk5crypto.3.1.dylib (0) <AB4E33BD-FD3B-3265-9D13-4DB7BFC71AAF> /nix/*/libk5crypto.3.1.dylib
       0x10729a000 -        0x10729afff +_opcode.cpython-36m-darwin.so (???) <94BA3E1E-D3CD-3B58-8428-3E701B41093A> /nix/*/_opcode.cpython-36m-darwin.so
       0x10729d000 -        0x10729effb +libcom_err.3.0.dylib (0) <C8990D19-55DA-3411-8895-CC7D8C35138F> /nix/*/libcom_err.3.0.dylib
       0x1072a1000 -        0x1072a2fff +_posixsubprocess.cpython-36m-darwin.so (???) <047B8A3C-C916-3B38-8130-3154F509BEFF> /nix/*/_posixsubprocess.cpython-36m-darwin.so
       0x1072a7000 -        0x1072adffb +libkrb5support.1.1.dylib (0) <E4B7CAA7-2ED2-348E-9043-62DA461C7C91> /nix/*/libkrb5support.1.1.dylib
       0x10773a000 -        0x107740fff +_struct.cpython-36m-darwin.so (???) <5C4B2605-7ABA-3FB5-B0C8-B720DC8CE4A7> /nix/*/_struct.cpython-36m-darwin.so
       0x1077d0000 -        0x1077d4fff +zlib.cpython-36m-darwin.so (???) <085D2657-6491-3A68-98E8-F582D28211D0> /nix/*/zlib.cpython-36m-darwin.so
       0x1077d9000 -        0x1077e9fff +libbz2.1.dylib (0) <89006BA2-B7C7-352A-9ED8-72FC93F39E1F> /nix/*/libbz2.1.dylib
       0x10782c000 -        0x107830ff7 +_lzma.cpython-36m-darwin.so (???) <2265DBA0-CCC6-3AAE-8D32-183F691F676E> /nix/*/_lzma.cpython-36m-darwin.so
       0x107835000 -        0x107854fff +liblzma.5.dylib (0) <E5EE127A-B99F-3674-AC53-2053AADDD343> /nix/*/liblzma.5.dylib
       0x10785a000 -        0x107861ff7 +math.cpython-36m-darwin.so (???) <86DDDBD9-1155-3FC5-B875-1BCCB3009CC1> /nix/*/math.cpython-36m-darwin.so
       0x107866000 -        0x107869fff +_hashlib.cpython-36m-darwin.so (???) <574759B3-042A-3082-9C35-A0076E1CE1E5> /nix/*/_hashlib.cpython-36m-darwin.so
       0x10786d000 -        0x1078ccff7 +libssl.1.1.dylib (0) <68719DC9-69D4-3ABD-92A0-79FE627AEF9D> /nix/*/libssl.1.1.dylib
       0x1078f5000 -        0x107ae6c1f +libcrypto.1.1.dylib (0) <B7825AD6-BDE6-3186-A6AC-3D1293EB47EA> /nix/*/libcrypto.1.1.dylib
       0x107b76000 -        0x107b7cfff +_blake2.cpython-36m-darwin.so (???) <33957568-2523-3567-906D-665E2A08132B> /nix/*/_blake2.cpython-36m-darwin.so
       0x107b80000 -        0x107b91ff7 +_sha3.cpython-36m-darwin.so (???) <CC16A512-9E8C-3796-9941-33ACAA4A9E43> /nix/*/_sha3.cpython-36m-darwin.so
       0x107c6a000 -        0x107c6dff7 +select.cpython-36m-darwin.so (???) <7178C79B-738D-3DDA-A45D-D1DA3BEED3DF> /nix/*/select.cpython-36m-darwin.so
       0x107cf2000 -        0x107cf5fff +_csv.cpython-36m-darwin.so (???) <368596C0-BF25-3723-9809-D25BCA9B2EEB> /nix/*/_csv.cpython-36m-darwin.so
       0x107d3a000 -        0x107d3dfff +binascii.cpython-36m-darwin.so (???) <995E612B-0897-353A-9958-65FEA02032F8> /nix/*/binascii.cpython-36m-darwin.so
       0x107e41000 -        0x107e4bfff +_socket.cpython-36m-darwin.so (???) <F21DA00E-DFD5-34C0-8ACA-725927AA6D66> /nix/*/_socket.cpython-36m-darwin.so
       0x107e95000 -        0x107ea4ff7 +_datetime.cpython-36m-darwin.so (???) <503C48E6-2FE2-35AB-9A1A-AE4F7D7E81A9> /nix/*/_datetime.cpython-36m-darwin.so
       0x1081bd000 -        0x108200fff +_decimal.cpython-36m-darwin.so (???) <00FAD6BB-6338-380C-9E6F-B7BD99C47086> /nix/*/_decimal.cpython-36m-darwin.so
       0x108313000 -        0x10831aff7 +_json.cpython-36m-darwin.so (???) <41AE9698-8233-378F-A0BA-7AE9947FC245> /nix/*/_json.cpython-36m-darwin.so
       0x10835e000 -        0x108434fff +unicodedata.cpython-36m-darwin.so (???) <FB0AC214-5CC6-3565-BB5F-B60F046192F7> /nix/*/unicodedata.cpython-36m-darwin.so
       0x1084f9000 -        0x10850dfff +_pickle.cpython-36m-darwin.so (???) <5D4ADF61-DA1B-381C-9FD7-91B6561063B7> /nix/*/_pickle.cpython-36m-darwin.so
       0x108517000 -        0x108519fff +tracer.cpython-36m-darwin.so (0) <C1659AF7-3C88-3951-8824-DBADC13466DB> /nix/*/tracer.cpython-36m-darwin.so
       0x1085dd000 -        0x1085e4fff +array.cpython-36m-darwin.so (???) <FED1D7BF-4AB2-3D1A-AAF3-6F27AE2AE9BE> /nix/*/array.cpython-36m-darwin.so
       0x1086eb000 -        0x1086f9ff7 +_ssl.cpython-36m-darwin.so (???) <58C6A9A5-9083-3B51-B098-D0A86AEB38EE> /nix/*/_ssl.cpython-36m-darwin.so
       0x108746000 -        0x108747fff +_scproxy.cpython-36m-darwin.so (???) <2530E5AD-804C-3DBE-A53F-04EAF643B7CC> /nix/*/_scproxy.cpython-36m-darwin.so
       0x10874a000 -        0x108796ff3  com.apple.SystemConfiguration (1.12.2 - 1.12.2) <B35616CA-8780-34DB-89FE-A5CEEA47A90D> /nix/*/SystemConfiguration.framework/SystemConfiguration
       0x108917000 -        0x108918ff3 +_speedups.cpython-36m-darwin.so (0) <A256DCFA-2FFC-3C5D-9BC6-E202EA2B0949> /nix/*/_speedups.cpython-36m-darwin.so
       0x1089e5000 -        0x1089e6ff7 +_multiprocessing.cpython-36m-darwin.so (???) <BA3CD43B-A3E4-3A81-93A3-71CA828AB78F> /nix/*/_multiprocessing.cpython-36m-darwin.so
       0x108a29000 -        0x108a2eff7 +_asyncio.cpython-36m-darwin.so (???) <2D03A676-BE5C-30AA-9777-248D3DD3E784> /nix/*/_asyncio.cpython-36m-darwin.so
       0x108df9000 -        0x108dfaffb +cprocessors.cpython-36m-darwin.so (0) <692A51F8-F468-3281-A0FD-39C3952BB3D7> /nix/*/cprocessors.cpython-36m-darwin.so
       0x108dfd000 -        0x108dfdffb +cutils.cpython-36m-darwin.so (0) <8C6ABB63-7D01-3380-A6DC-47B3E74989CC> /nix/*/cutils.cpython-36m-darwin.so
       0x1090ee000 -        0x1090efffb +cresultproxy.cpython-36m-darwin.so (0) <396D6918-E57D-3603-8C08-C11D41A3A0C3> /nix/*/cresultproxy.cpython-36m-darwin.so
       0x1098d3000 -        0x1098e6ff7 +_ctypes.cpython-36m-darwin.so (???) <8AFA4D0C-7EA1-36D2-8874-472DFD0361D2> /nix/*/_ctypes.cpython-36m-darwin.so
       0x1098f1000 -        0x1098f6ff7 +libffi.6.dylib (0) <06D7A7A5-FB71-373F-A23F-9BF3B0DC2BC8> /nix/*/libffi.6.dylib
       0x109957000 -        0x109958ff3 +_constant_time.abi3.so (0) <4EF6F8C1-4952-3404-A608-E157533E1FF8> /nix/*/_constant_time.abi3.so
       0x10995b000 -        0x109977ff3 +_cffi_backend.cpython-36m-darwin.so (0) <52529F8B-0C8F-3760-B9F5-AAE33B8B069D> /nix/*/_cffi_backend.cpython-36m-darwin.so
       0x1099e8000 -        0x1099e9fff +_rjsmin.cpython-36m-darwin.so (0) <212A3869-4C24-377C-85B9-5601F020B8E7> /nix/*/_rjsmin.cpython-36m-darwin.so
       0x1099ec000 -        0x1099edfff +termios.cpython-36m-darwin.so (???) <22773E18-8F4E-353E-9443-484684932FED> /nix/*/termios.cpython-36m-darwin.so
       0x1099f1000 -        0x1099f2ffb +_padding.abi3.so (0) <F648E0C8-3CAA-39EB-B06D-38FEB4767B29> /nix/*/_padding.abi3.so
       0x109a85000 -        0x109ae8ffb +_openssl.abi3.so (0) <564479B8-33DC-3BAD-9826-D57D9E0C8198> /nix/*/_openssl.abi3.so
       0x109eae000 -        0x109ebeff7 +_hoedown.abi3.so (0) <4572C822-D79A-3338-92EF-C1361946612C> /nix/*/_hoedown.abi3.so
       0x10a1ae000 -        0x10a1cdfff +_psycopg.cpython-36m-darwin.so (0) <A4BBCD35-AF8E-3D24-9490-DFA856F5409B> /nix/*/_psycopg.cpython-36m-darwin.so
       0x10a1de000 -        0x10a214ffb +libpq.5.dylib (0) <A57F3AAE-D0B1-311C-8855-8A9866F2425A> /nix/*/libpq.5.dylib
       0x10a3e0000 -        0x10a3ecfff +pyexpat.cpython-36m-darwin.so (???) <BFF922CC-2485-3790-87AF-2C9D9C6760AA> /nix/*/pyexpat.cpython-36m-darwin.so
       0x10a3f3000 -        0x10a414ff7 +libexpat.1.dylib (0) <98357E18-8248-34D3-B2D1-19F487954805> /nix/*/libexpat.1.dylib
       0x111ecd000 -        0x111f3770f  dyld (655.1.1) <DFC3C4AF-6F97-3B34-B18D-7DCB23F2A83A> /usr/lib/dyld
    0x7fff65828000 -     0x7fff65829fff  com.apple.TrustEvaluationAgent (2.0 - 31.200.1) <15DF9C73-54E4-3C41-BCF4-378338C55FB4> /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
    0x7fff67af2000 -     0x7fff67af3ffb  libSystem.B.dylib (1252.250.1) <B1006948-7AD0-3CA9-81E0-833F4DD6BFB4> /usr/lib/libSystem.B.dylib
    0x7fff67d35000 -     0x7fff67d88ff7  libc++.1.dylib (400.9.4) <9A60A190-6C34-339F-BB3D-AACE942009A4> /usr/lib/libc++.1.dylib
    0x7fff67d89000 -     0x7fff67d9eff7  libc++abi.dylib (400.17) <38C09CED-9090-3719-90F3-04A2749F5428> /usr/lib/libc++abi.dylib
    0x7fff681f4000 -     0x7fff682ecff7  libcrypto.35.dylib (22.260.1) <91C3D71A-4D1D-331D-89CC-67863DF10574> /usr/lib/libcrypto.35.dylib
    0x7fff69329000 -     0x7fff69aaefdf  libobjc.A.dylib (756.2) <7C312627-43CB-3234-9324-4DEA92D59F50> /usr/lib/libobjc.A.dylib
    0x7fff6a98e000 -     0x7fff6a992ff3  libcache.dylib (81) <1987D1E1-DB11-3291-B12A-EBD55848E02D> /usr/lib/system/libcache.dylib
    0x7fff6a993000 -     0x7fff6a99dff3  libcommonCrypto.dylib (60118.250.2) <1765BB6E-6784-3653-B16B-CB839721DC9A> /usr/lib/system/libcommonCrypto.dylib
    0x7fff6a99e000 -     0x7fff6a9a5ff7  libcompiler_rt.dylib (63.4) <5212BA7B-B7EA-37B4-AF6E-AC4F507EDFB8> /usr/lib/system/libcompiler_rt.dylib
    0x7fff6a9a6000 -     0x7fff6a9afff7  libcopyfile.dylib (146.250.1) <98CD00CD-9B91-3B5C-A9DB-842638050FA8> /usr/lib/system/libcopyfile.dylib
    0x7fff6a9b0000 -     0x7fff6aa34fc3  libcorecrypto.dylib (602.260.2) <01464D24-570C-3B83-9D18-467769E0FCDD> /usr/lib/system/libcorecrypto.dylib
    0x7fff6aabb000 -     0x7fff6aaf4ff7  libdispatch.dylib (1008.270.1) <97273678-E94C-3C8C-89F6-2E2020F4B43B> /usr/lib/system/libdispatch.dylib
    0x7fff6aaf5000 -     0x7fff6ab21ff7  libdyld.dylib (655.1.1) <002418CC-AD11-3D10-865B-015591D24E6C> /usr/lib/system/libdyld.dylib
    0x7fff6ab22000 -     0x7fff6ab22ffb  libkeymgr.dylib (30) <0D0F9CA2-8D5A-3273-8723-59987B5827F2> /usr/lib/system/libkeymgr.dylib
    0x7fff6ab30000 -     0x7fff6ab30ff7  liblaunch.dylib (1336.261.2) <2B07E27E-D404-3E98-9D28-BCA641E5C479> /usr/lib/system/liblaunch.dylib
    0x7fff6ab31000 -     0x7fff6ab36fff  libmacho.dylib (927.0.3) <A377D608-77AB-3F6E-90F0-B4F251A5C12F> /usr/lib/system/libmacho.dylib
    0x7fff6ab37000 -     0x7fff6ab39ffb  libquarantine.dylib (86.220.1) <6D0BC770-7348-3608-9254-F7FFBD347634> /usr/lib/system/libquarantine.dylib
    0x7fff6ab3a000 -     0x7fff6ab3bff7  libremovefile.dylib (45.200.2) <9FBEB2FF-EEBE-31BC-BCFC-C71F8D0E99B6> /usr/lib/system/libremovefile.dylib
    0x7fff6ab3c000 -     0x7fff6ab53ff3  libsystem_asl.dylib (356.200.4) <A62A7249-38B8-33FA-9875-F1852590796C> /usr/lib/system/libsystem_asl.dylib
    0x7fff6ab54000 -     0x7fff6ab54ff7  libsystem_blocks.dylib (73) <A453E8EE-860D-3CED-B5DC-BE54E9DB4348> /usr/lib/system/libsystem_blocks.dylib
    0x7fff6ab55000 -     0x7fff6abdcfff  libsystem_c.dylib (1272.250.1) <7EDACF78-2FA3-35B8-B051-D70475A35117> /usr/lib/system/libsystem_c.dylib
    0x7fff6abdd000 -     0x7fff6abe0ffb  libsystem_configuration.dylib (963.270.3) <2B4A836D-68A4-33E6-8D48-CD4486B03387> /usr/lib/system/libsystem_configuration.dylib
    0x7fff6abe1000 -     0x7fff6abe4ff7  libsystem_coreservices.dylib (66) <719F75A4-74C5-3BA6-A09E-0C5A3E5889D7> /usr/lib/system/libsystem_coreservices.dylib
    0x7fff6abe5000 -     0x7fff6abebfff  libsystem_darwin.dylib (1272.250.1) <EC9B39A5-9592-3577-8997-7DC721D20D8C> /usr/lib/system/libsystem_darwin.dylib
    0x7fff6abec000 -     0x7fff6abf2ff7  libsystem_dnssd.dylib (878.270.2) <E9A5ACCF-E35F-3909-AF0A-2A37CD217276> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff6abf3000 -     0x7fff6ac3effb  libsystem_info.dylib (517.200.9) <D09D5AE0-2FDC-3A6D-93EC-729F931B1457> /usr/lib/system/libsystem_info.dylib
    0x7fff6ac3f000 -     0x7fff6ac67ff7  libsystem_kernel.dylib (4903.271.2) <EA204E3C-870B-30DD-B4AF-D1BB66420D14> /usr/lib/system/libsystem_kernel.dylib
    0x7fff6ac68000 -     0x7fff6acb3ff7  libsystem_m.dylib (3158.200.7) <F19B6DB7-014F-3820-831F-389CCDA06EF6> /usr/lib/system/libsystem_m.dylib
    0x7fff6acb4000 -     0x7fff6acdefff  libsystem_malloc.dylib (166.270.1) <011F3AD0-8E6A-3A89-AE64-6E5F6840F30A> /usr/lib/system/libsystem_malloc.dylib
    0x7fff6acdf000 -     0x7fff6ace9ff7  libsystem_networkextension.dylib (767.250.2) <FF06F13A-AEFE-3A27-A073-910EF78AEA36> /usr/lib/system/libsystem_networkextension.dylib
    0x7fff6acea000 -     0x7fff6acf1fff  libsystem_notify.dylib (172.200.21) <145B5CFC-CF73-33CE-BD3D-E8DDE268FFDE> /usr/lib/system/libsystem_notify.dylib
    0x7fff6acf2000 -     0x7fff6acfbfef  libsystem_platform.dylib (177.270.1) <9D1FE5E4-EB7D-3B3F-A8D1-A96D9CF1348C> /usr/lib/system/libsystem_platform.dylib
    0x7fff6acfc000 -     0x7fff6ad06ff7  libsystem_pthread.dylib (330.250.2) <2D5C08FF-484F-3D59-9132-CE1DCB3F76D7> /usr/lib/system/libsystem_pthread.dylib
    0x7fff6ad07000 -     0x7fff6ad0aff7  libsystem_sandbox.dylib (851.270.1) <9494594B-5199-3186-82AB-5FF8BED6EE16> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff6ad0b000 -     0x7fff6ad0dff3  libsystem_secinit.dylib (30.260.2) <EF1EA47B-7B22-35E8-BD9B-F7003DCB96AE> /usr/lib/system/libsystem_secinit.dylib
    0x7fff6ad0e000 -     0x7fff6ad15ff3  libsystem_symptoms.dylib (820.267.1) <03F1C2DD-0F5A-3D9D-88F6-B26C0F94EB52> /usr/lib/system/libsystem_symptoms.dylib
    0x7fff6ad16000 -     0x7fff6ad2bfff  libsystem_trace.dylib (906.260.1) <FC761C3B-5434-3A52-912D-F1B15FAA8EB2> /usr/lib/system/libsystem_trace.dylib
    0x7fff6ad2c000 -     0x7fff6ad2cff7  libunc.dylib (30) <946AD970-D655-3526-AB11-F4FE52222E0B> /usr/lib/system/libunc.dylib
    0x7fff6ad2d000 -     0x7fff6ad32ffb  libunwind.dylib (35.4) <24A97A67-F017-3CFC-B0D0-6BD0224B1336> /usr/lib/system/libunwind.dylib
    0x7fff6ad33000 -     0x7fff6ad62fff  libxpc.dylib (1336.261.2) <7DEE2300-6D8E-3C00-9C63-E3E80D56B0C4> /usr/lib/system/libxpc.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 51493004
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=256.9M resident=0K(0%) swapped_out_or_unallocated=256.9M(100%)
Writable regions: Total=107.2M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=107.2M(100%)
 
                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
Kernel Alloc Once                    8K        1 
MALLOC                            49.8M       35 
MALLOC guard page                   16K        4 
MALLOC_LARGE (reserved)            384K        3         reserved VM address space (unallocated)
STACK GUARD                       56.0M        1 
Stack                             8192K        1 
VM_ALLOCATE                       48.5M       51 
__DATA                            4412K      123 
__LINKEDIT                       226.7M       78 
__TEXT                            30.2M      117 
__UNICODE                          560K        1 
shared memory                       12K        3 
===========                     =======  ======= 
TOTAL                            424.8M      419 
TOTAL, minus reserved VM space   424.4M      419 

Today I disabled my workaround to ensure I still see the issue and noticed that something (maybe pytest--I was using 4.x at the time and now use 5.x) in my environment has shifted and the test run now prints helpful Python segfault messages and full stack traces. Here's an example:

segfault stack trace
Fatal Python error: Segmentation fault

Current thread 0x00000001121c05c0 (most recent call first):
  File "/nix/store/ajn7df20f65rb00pjkayr82dppyszsn8-python3-3.6.9/lib/python3.6/socketserver.py", line 470 in server_bind
  File "/nix/store/ajn7df20f65rb00pjkayr82dppyszsn8-python3-3.6.9/lib/python3.6/http/server.py", line 136 in server_bind
  File "/nix/store/ajn7df20f65rb00pjkayr82dppyszsn8-python3-3.6.9/lib/python3.6/socketserver.py", line 456 in __init__
  File "/nix/store/ai2cvzkgzgjq4j38rwvgym81jj8vqs1r-python3.6-Werkzeug-0.12.2/lib/python3.6/site-packages/werkzeug/serving.py", line 504 in __init__
  File "/nix/store/ai2cvzkgzgjq4j38rwvgym81jj8vqs1r-python3.6-Werkzeug-0.12.2/lib/python3.6/site-packages/werkzeug/serving.py", line 587 in make_server
  File "/nix/store/ai2cvzkgzgjq4j38rwvgym81jj8vqs1r-python3.6-Werkzeug-0.12.2/lib/python3.6/site-packages/werkzeug/serving.py", line 699 in inner
  File "/nix/store/ai2cvzkgzgjq4j38rwvgym81jj8vqs1r-python3.6-Werkzeug-0.12.2/lib/python3.6/site-packages/werkzeug/serving.py", line 739 in run_simple
  File "/nix/store/2wsznll072jgsaqp3ypmd354s9yqw9vw-python3.6-Flask-0.12.2/lib/python3.6/site-packages/flask/app.py", line 841 in run
  File "/nix/store/dsdjvybj8bp9cpqw3hzl2fjd0gns0p8d-python3.6-pytest-flask-0.14.0/lib/python3.6/site-packages/pytest_flask/fixtures.py", line 67 in worker
  File "/nix/store/ajn7df20f65rb00pjkayr82dppyszsn8-python3-3.6.9/lib/python3.6/multiprocessing/process.py", line 93 in run
  File "/nix/store/ajn7df20f65rb00pjkayr82dppyszsn8-python3-3.6.9/lib/python3.6/multiprocessing/process.py", line 258 in _bootstrap
  File "/nix/store/ajn7df20f65rb00pjkayr82dppyszsn8-python3-3.6.9/lib/python3.6/multiprocessing/popen_fork.py", line 73 in _launch
  File "/nix/store/ajn7df20f65rb00pjkayr82dppyszsn8-python3-3.6.9/lib/python3.6/multiprocessing/popen_fork.py", line 19 in __init__
  File "/nix/store/ajn7df20f65rb00pjkayr82dppyszsn8-python3-3.6.9/lib/python3.6/multiprocessing/context.py", line 277 in _Popen
  File "/nix/store/ajn7df20f65rb00pjkayr82dppyszsn8-python3-3.6.9/lib/python3.6/multiprocessing/context.py", line 223 in _Popen
  File "/nix/store/ajn7df20f65rb00pjkayr82dppyszsn8-python3-3.6.9/lib/python3.6/multiprocessing/process.py", line 105 in start
  File "/nix/store/dsdjvybj8bp9cpqw3hzl2fjd0gns0p8d-python3.6-pytest-flask-0.14.0/lib/python3.6/site-packages/pytest_flask/fixtures.py", line 72 in start
  File "/Users/abathur/<intentionally snipped>/tests/conftest.py", line 963 in browser
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 775 in call_fixture_func
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 949 in pytest_fixture_setup
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/manager.py", line 86 in <lambda>
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/manager.py", line 92 in _hookexec
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 900 in execute
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 571 in _compute_fixture_value
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 490 in _get_active_fixturedef
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 880 in execute
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 571 in _compute_fixture_value
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 490 in _get_active_fixturedef
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 880 in execute
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 571 in _compute_fixture_value
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 490 in _get_active_fixturedef
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 474 in getfixturevalue
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 464 in _fillfixtures
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/fixtures.py", line 291 in fillfixtures
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/python.py", line 1427 in setup
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/runner.py", line 366 in prepare
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/runner.py", line 118 in pytest_runtest_setup
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/manager.py", line 86 in <lambda>
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/manager.py", line 92 in _hookexec
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/runner.py", line 201 in <lambda>
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/runner.py", line 229 in from_call
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/runner.py", line 201 in call_runtest_hook
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/runner.py", line 176 in call_and_report
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/runner.py", line 89 in runtestprotocol
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/runner.py", line 80 in pytest_runtest_protocol
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/manager.py", line 86 in <lambda>
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/manager.py", line 92 in _hookexec
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/main.py", line 256 in pytest_runtestloop
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/manager.py", line 86 in <lambda>
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/manager.py", line 92 in _hookexec
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/main.py", line 235 in _main
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/main.py", line 191 in wrap_session
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/main.py", line 228 in pytest_cmdline_main
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/manager.py", line 86 in <lambda>
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/manager.py", line 92 in _hookexec
  File "/nix/store/njj7nw68w2kxf8z6d2s1b5zw8l2dzw3m-python3.6-pluggy-0.13.0/lib/python3.6/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/lib/python3.6/site-packages/_pytest/config/__init__.py", line 90 in main
  File "/nix/store/j44z35nkdkn527j7r93iajm0sv6h0678-python3.6-pytest-5.2.1/bin/.pytest-wrapped", line 11 in <module>

Workaround

At least in our case, threads proved a viable workaround. I achieved this by subclassing LiveServer and overriding the live_server fixture in our conftest:

from pytest_flask.fixtures import LiveServer, _rewrite_server_name
import socket
from threading import Thread

try:
    from urllib2 import URLError, urlopen
except ImportError:
    from urllib.error import URLError
    from urllib.request import urlopen

class PatchedLiveServer(LiveServer):
    def start(self):
        """Start application in a separate process."""
        self._process = Thread(
            target=self.app.run,
            kwargs=dict(
                host=self.host, port=self.port, use_reloader=False, threaded=False
            ),
            daemon=True,
        )
        self._process.start()

        # We must wait for the server to start listening with a maximum
        # timeout of 5 seconds.
        timeout = 5
        while timeout > 0:
            time.sleep(1)
            try:
                urlopen(self.url())
                timeout = 0
            except URLError:
                timeout -= 1

    def stop(self):
        # inherited stop will break (thread has no terminate, join may fail)
        pass

@pytest.fixture(scope="function")
def live_server(request, app, monkeypatch, pytestconfig):
    port = pytestconfig.getvalue("live_server_port")

    if port == 0:
        # Bind to an open port
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.bind(("", 0))
        port = s.getsockname()[1]
        s.close()

    host = pytestconfig.getvalue("live_server_host")

    # Explicitly set application ``SERVER_NAME`` for test suite
    # and restore original value on test teardown.
    server_name = app.config["SERVER_NAME"] or "localhost"
    monkeypatch.setitem(
        app.config, "SERVER_NAME", _rewrite_server_name(server_name, str(port))
    )

    clean_stop = request.config.getvalue("live_server_clean_stop")
    server = PatchedLiveServer(app, host, port, clean_stop)
    if request.config.getvalue("start_live_server"):
        server.start()

    request.addfinalizer(server.stop)
    return server
@northernSage northernSage added the stale This issue has not seen activity for a while label Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This issue has not seen activity for a while
Projects
None yet
Development

No branches or pull requests

2 participants