Show More
@@ -277,8 +277,12 b' class abstractvfs(object):' | |||
|
277 | 277 | to ``__call__``/``open`` to result in the file possibly being closed |
|
278 | 278 | asynchronously, on a background thread. |
|
279 | 279 | """ |
|
280 | # This is an arbitrary restriction and could be changed if we ever | |
|
281 | # have a use case. | |
|
280 | # Sharing backgroundfilecloser between threads is complex and using | |
|
281 | # multiple instances puts us at risk of running out of file descriptors | |
|
282 | # only allow to use backgroundfilecloser when in main thread. | |
|
283 | if not isinstance(threading.currentThread(), threading._MainThread): | |
|
284 | yield | |
|
285 | return | |
|
282 | 286 | vfs = getattr(self, 'vfs', self) |
|
283 | 287 | if getattr(vfs, '_backgroundfilecloser', None): |
|
284 | 288 | raise error.Abort( |
@@ -413,7 +417,8 b' class vfs(abstractvfs):' | |||
|
413 | 417 | ' valid for checkambig=True') % mode) |
|
414 | 418 | fp = checkambigatclosing(fp) |
|
415 | 419 | |
|
416 |
if backgroundclose |
|
|
420 | if (backgroundclose and | |
|
421 | isinstance(threading.currentThread(), threading._MainThread)): | |
|
417 | 422 | if not self._backgroundfilecloser: |
|
418 | 423 | raise error.Abort(_('backgroundclose can only be used when a ' |
|
419 | 424 | 'backgroundclosing context manager is active') |
General Comments 0
You need to be logged in to leave comments.
Login now