##// END OF EJS Templates
workers: don't use backgroundfilecloser in threads...
Wojciech Lis -
r35426:60f2a215 default
parent child Browse files
Show More
@@ -277,8 +277,12 b' class abstractvfs(object):'
277 to ``__call__``/``open`` to result in the file possibly being closed
277 to ``__call__``/``open`` to result in the file possibly being closed
278 asynchronously, on a background thread.
278 asynchronously, on a background thread.
279 """
279 """
280 # This is an arbitrary restriction and could be changed if we ever
280 # Sharing backgroundfilecloser between threads is complex and using
281 # have a use case.
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 vfs = getattr(self, 'vfs', self)
286 vfs = getattr(self, 'vfs', self)
283 if getattr(vfs, '_backgroundfilecloser', None):
287 if getattr(vfs, '_backgroundfilecloser', None):
284 raise error.Abort(
288 raise error.Abort(
@@ -413,7 +417,8 b' class vfs(abstractvfs):'
413 ' valid for checkambig=True') % mode)
417 ' valid for checkambig=True') % mode)
414 fp = checkambigatclosing(fp)
418 fp = checkambigatclosing(fp)
415
419
416 if backgroundclose:
420 if (backgroundclose and
421 isinstance(threading.currentThread(), threading._MainThread)):
417 if not self._backgroundfilecloser:
422 if not self._backgroundfilecloser:
418 raise error.Abort(_('backgroundclose can only be used when a '
423 raise error.Abort(_('backgroundclose can only be used when a '
419 'backgroundclosing context manager is active')
424 'backgroundclosing context manager is active')
General Comments 0
You need to be logged in to leave comments. Login now