Commit 9637209
authored
* Bug fix: KeyboardInterrupt while copying data from an mmapped region
In the XShmGetImage backend, there was a window of time during which a
KeyboardInterrupt (or other asynchronous exception) would cause
cleanup of the MSS object to raise a different exception. This is one
of the slower parts of this backend, so it's a time when asynchronous
exceptions can hit pretty easily.
While a Python library almost never can guarantee correctness
following an asynchronous exception, ending a program with Ctrl-C is
not uncommon. We can't guarantee correctness in all circumstances,
and shouldn't try to.
All this patch does is to avoid the exception that may be hard for an
end user to understand. Instead, the top-level user code will now see
the KeyboardInterrupt, and not the seemingly-unrelated cleanup
exception.
* Switch to a simpler implementation
I just learned that memoryviews can be used as context managers, and
release their buffers at the end of that, instead of having to be
GC'd.
1 parent e5888a7 commit 9637209
1 file changed
Lines changed: 6 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
206 | 197 | | |
207 | 198 | | |
208 | 199 | | |
| |||
0 commit comments