Skip to content

Commit 8abc71a

Browse files
Add files via upload
1 parent fb89f8e commit 8abc71a

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

pyfoxfile.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ def _is_printable(ch):
416416
__use_inmemfile__ = True
417417
__use_spoolfile__ = False
418418
__use_spooldir__ = tempfile.gettempdir()
419+
BYTES_PER_MiB = 1024 * 1024
420+
DEFAULT_SPOOL_MAX = 8 * BYTES_PER_MiB
421+
__use_spooldir__ = DEFAULT_SPOOL_MAX
419422
__program_name__ = "Py"+__file_format_default__
420423
__use_env_file__ = True
421424
__use_ini_file__ = True
@@ -1973,7 +1976,7 @@ def MkTempFile(data=None,
19731976
dir=None,
19741977
suffix="",
19751978
use_spool=__use_spoolfile__,
1976-
spool_max=8 * 1024 * 1024,
1979+
spool_max=__use_spooldir__,
19771980
spool_dir=__use_spooldir__:
19781981
"""
19791982
Return a file-like handle with consistent behavior on Py2.7 and Py3.x.
@@ -2417,7 +2420,7 @@ class ZlibFile(object):
24172420

24182421
def __init__(self, file_path=None, fileobj=None, mode='rb', level=6, wbits=15,
24192422
encoding=None, errors=None, newline=None,
2420-
tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=(8 << 20)):
2423+
tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=__use_spooldir__):
24212424

24222425
if file_path is None and fileobj is None:
24232426
raise ValueError("Either file_path or fileobj must be provided")
@@ -2904,7 +2907,7 @@ class GzipFile(object):
29042907

29052908
def __init__(self, file_path=None, fileobj=None, mode='rb',
29062909
level=6, encoding=None, errors=None, newline=None,
2907-
tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=(8 << 20)):
2910+
tolerant_read=False, scan_bytes=(64 << 10), spool_threshold=__use_spooldir__):
29082911

29092912
if file_path is None and fileobj is None:
29102913
raise ValueError("Either file_path or fileobj must be provided")
@@ -3350,7 +3353,7 @@ def __init__(self, file_path=None, fileobj=None, mode='rb',
33503353
level=9, encoding=None, errors=None, newline=None,
33513354
write_header=True,
33523355
tolerant_read=False, scan_bytes=(64 << 10),
3353-
spool_threshold=(8 << 20)):
3356+
spool_threshold=__use_spooldir__):
33543357
"""
33553358
Custom LZO file (NOT the lzop(1) format).
33563359
- streaming write/read, supports concatenated members
@@ -3825,7 +3828,7 @@ def lzop_compress_bytes(payload, level=9, text=False, **kw):
38253828

38263829

38273830
def lzop_decompress_bytes(blob, mode='rb', tolerant_read=False, scan_bytes=(64 << 10),
3828-
spool_threshold=(8 << 20), **kw):
3831+
spool_threshold=__use_spooldir__, **kw):
38293832
"""
38303833
Decompress bytes produced by this custom container.
38313834
- mode='rb' -> returns bytes; mode='rt' -> returns text (set encoding/errors/newline in kw)
@@ -9793,7 +9796,7 @@ def fast_copy(infp, outfp, bufsize=1 << 20):
97939796
outfp.write(data)
97949797

97959798

9796-
def copy_file_to_mmap_dest(src_path, outfp, chunk_size=8 << 20):
9799+
def copy_file_to_mmap_dest(src_path, outfp, chunk_size=__use_spooldir__):
97979800
"""
97989801
Copy a disk file into an mmap-backed destination (FileLikeAdapter).
97999802
Falls back to buffered copy if the source cannot be mmapped.

0 commit comments

Comments
 (0)