2840
2841
:returns: result of calling func
2841
2842
:raises: whatever func raises
2845
raise swift.common.exceptions.ThreadPoolDead()
2843
2847
if self.nthreads <= 0:
2844
2848
result = func(*args, **kwargs)
2884
2888
:returns: result of calling func
2885
2889
:raises: whatever func raises
2892
raise swift.common.exceptions.ThreadPoolDead()
2887
2894
if self.nthreads <= 0:
2888
2895
return self._run_in_eventlet_tpool(func, *args, **kwargs)
2890
2897
return self.run_in_thread(func, *args, **kwargs)
2899
def terminate(self):
2901
Releases the threadpool's resources (OS threads, greenthreads, pipes,
2902
etc.) and renders it unusable.
2904
Don't call run_in_thread() or force_run_in_thread() after calling
2908
if self.nthreads <= 0:
2911
for _junk in range(self.nthreads):
2912
self._run_queue.put(None)
2913
for thr in self._threads:
2918
greenthread.kill(self._consumer_coro)
2921
os.close(self.wpipe)
2893
2924
def ismount(path):
3218
3249
raise IOError(ctypes.get_errno(), "Failed to accept MD5 socket")
3220
3251
return md5_sockfd
3223
# Flags for splice() and tee()
3225
SPLICE_F_NONBLOCK = 2
3230
def splice(fd_in, off_in, fd_out, off_out, length, flags):
3232
Calls splice - a Linux-specific syscall for zero-copy data movement.
3234
On success, returns the number of bytes moved.
3236
On failure where errno is EWOULDBLOCK, returns None.
3238
On all other failures, raises IOError.
3241
if _libc_splice is None:
3242
_libc_splice = load_libc_function('splice', fail_if_missing=True)
3244
ret = _libc_splice(ctypes.c_int(fd_in), ctypes.c_long(off_in),
3245
ctypes.c_int(fd_out), ctypes.c_long(off_out),
3246
ctypes.c_int(length), ctypes.c_int(flags))
3248
err = ctypes.get_errno()
3249
if err == errno.EWOULDBLOCK:
3252
raise IOError(err, "splice() failed: %s" % os.strerror(err))
3256
def tee(fd_in, fd_out, length, flags):
3258
Calls tee - a Linux-specific syscall to let pipes share data.
3260
On success, returns the number of bytes "copied".
3262
On failure, raises IOError.
3265
if _libc_tee is None:
3266
_libc_tee = load_libc_function('tee', fail_if_missing=True)
3268
ret = _libc_tee(ctypes.c_int(fd_in), ctypes.c_int(fd_out),
3269
ctypes.c_int(length), ctypes.c_int(flags))
3271
err = ctypes.get_errno()
3272
raise IOError(err, "tee() failed: %s" % os.strerror(err))
3276
def system_has_splice():
3279
_libc_splice = load_libc_function('splice', fail_if_missing=True)
3281
except AttributeError: