0s autopkgtest [21:37:16]: starting date and time: 2024-12-02 21:37:16+0000 0s autopkgtest [21:37:16]: git checkout: be626eda Fix armhf LXD image generation for plucky 0s autopkgtest [21:37:16]: host juju-7f2275-prod-proposed-migration-environment-20; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.t7ctpw77/out --timeout-copy=6000 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:tiktoken,src:python3-defaults,src:tiktoken --apt-upgrade tiktoken --timeout-short=300 --timeout-copy=20000 --timeout-build=20000 '--env=ADT_TEST_TRIGGERS=tiktoken/0.8.0-1build1 python3-defaults/3.12.7-1 tiktoken/0.8.0-1build1' -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor autopkgtest-s390x --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-20@bos03-s390x-5.secgroup --name adt-plucky-s390x-tiktoken-20241202-213716-juju-7f2275-prod-proposed-migration-environment-20-2348e5b9-3fca-4792-9cab-f91fef646b3c --image adt/ubuntu-plucky-s390x-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-20 --net-id=net_prod-proposed-migration-s390x -e TERM=linux -e ''"'"'http_proxy=http://squid.internal:3128'"'"'' -e ''"'"'https_proxy=http://squid.internal:3128'"'"'' -e ''"'"'no_proxy=127.0.0.1,127.0.1.1,login.ubuntu.com,localhost,localdomain,novalocal,internal,archive.ubuntu.com,ports.ubuntu.com,security.ubuntu.com,ddebs.ubuntu.com,changelogs.ubuntu.com,keyserver.ubuntu.com,launchpadlibrarian.net,launchpadcontent.net,launchpad.net,10.24.0.0/24,keystone.ps5.canonical.com,objectstorage.prodstack5.canonical.com'"'"'' --mirror=http://ftpmaster.internal/ubuntu/ 315s autopkgtest-virt-ssh: WARNING: ssh connection failed. Retrying in 3 seconds... 320s autopkgtest [21:42:36]: testbed dpkg architecture: s390x 321s autopkgtest [21:42:37]: testbed apt version: 2.9.14ubuntu1 321s autopkgtest [21:42:37]: @@@@@@@@@@@@@@@@@@@@ test bed setup 321s autopkgtest [21:42:37]: testbed release detected to be: None 322s autopkgtest [21:42:38]: updating testbed package index (apt update) 322s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed InRelease [73.9 kB] 322s Hit:2 http://ftpmaster.internal/ubuntu plucky InRelease 322s Hit:3 http://ftpmaster.internal/ubuntu plucky-updates InRelease 322s Hit:4 http://ftpmaster.internal/ubuntu plucky-security InRelease 322s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse Sources [15.1 kB] 322s Get:6 http://ftpmaster.internal/ubuntu plucky-proposed/main Sources [67.5 kB] 322s Get:7 http://ftpmaster.internal/ubuntu plucky-proposed/restricted Sources [9708 B] 322s Get:8 http://ftpmaster.internal/ubuntu plucky-proposed/universe Sources [775 kB] 322s Get:9 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x Packages [122 kB] 322s Get:10 http://ftpmaster.internal/ubuntu plucky-proposed/restricted s390x Packages [928 B] 322s Get:11 http://ftpmaster.internal/ubuntu plucky-proposed/universe s390x Packages [636 kB] 323s Get:12 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse s390x Packages [7964 B] 323s Fetched 1708 kB in 1s (1977 kB/s) 323s Reading package lists... 324s Reading package lists... 324s Building dependency tree... 324s Reading state information... 324s Calculating upgrade... 324s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 324s Reading package lists... 324s Building dependency tree... 324s Reading state information... 324s 0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded. 324s autopkgtest [21:42:40]: upgrading testbed (apt dist-upgrade and autopurge) 324s Reading package lists... 325s Building dependency tree... 325s Reading state information... 325s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 325s Starting 2 pkgProblemResolver with broken count: 0 325s Done 325s Entering ResolveByKeep 325s 325s The following packages will be upgraded: 325s libpython3-stdlib python3 python3-minimal 325s 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 325s Need to get 61.4 kB of archives. 325s After this operation, 0 B of additional disk space will be used. 325s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x python3-minimal s390x 3.12.7-1 [27.4 kB] 325s Get:2 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x python3 s390x 3.12.7-1 [24.0 kB] 326s Get:3 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x libpython3-stdlib s390x 3.12.7-1 [10.0 kB] 326s Fetched 61.4 kB in 0s (161 kB/s) 326s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 55869 files and directories currently installed.) 326s Preparing to unpack .../python3-minimal_3.12.7-1_s390x.deb ... 326s Unpacking python3-minimal (3.12.7-1) over (3.12.6-0ubuntu1) ... 326s Setting up python3-minimal (3.12.7-1) ... 326s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 55869 files and directories currently installed.) 326s Preparing to unpack .../python3_3.12.7-1_s390x.deb ... 326s Unpacking python3 (3.12.7-1) over (3.12.6-0ubuntu1) ... 326s Preparing to unpack .../libpython3-stdlib_3.12.7-1_s390x.deb ... 326s Unpacking libpython3-stdlib:s390x (3.12.7-1) over (3.12.6-0ubuntu1) ... 326s Setting up libpython3-stdlib:s390x (3.12.7-1) ... 326s Setting up python3 (3.12.7-1) ... 326s Processing triggers for man-db (2.13.0-1) ... 327s Reading package lists... 327s Building dependency tree... 327s Reading state information... 327s Starting pkgProblemResolver with broken count: 0 327s Starting 2 pkgProblemResolver with broken count: 0 327s Done 327s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 329s autopkgtest [21:42:45]: testbed running kernel: Linux 6.11.0-8-generic #8-Ubuntu SMP Mon Sep 16 12:49:35 UTC 2024 330s autopkgtest [21:42:46]: @@@@@@@@@@@@@@@@@@@@ apt-source tiktoken 331s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed/universe tiktoken 0.8.0-1build1 (dsc) [2247 B] 331s Get:2 http://ftpmaster.internal/ubuntu plucky-proposed/universe tiktoken 0.8.0-1build1 (tar) [31.6 kB] 331s Get:3 http://ftpmaster.internal/ubuntu plucky-proposed/universe tiktoken 0.8.0-1build1 (diff) [3908 B] 331s gpgv: Signature made Mon Nov 18 15:38:19 2024 UTC 331s gpgv: using RSA key 25E3FF2D7F469DBE7D0D4E50AFCFEC8E669CE1C2 331s gpgv: Can't check signature: No public key 331s dpkg-source: warning: cannot verify inline signature for ./tiktoken_0.8.0-1build1.dsc: no acceptable signature found 331s autopkgtest [21:42:47]: testing package tiktoken version 0.8.0-1build1 331s autopkgtest [21:42:47]: build not needed 332s autopkgtest [21:42:48]: test pybuild-autopkgtest: preparing testbed 332s Reading package lists... 332s Building dependency tree... 332s Reading state information... 332s Starting pkgProblemResolver with broken count: 0 332s Starting 2 pkgProblemResolver with broken count: 0 332s Done 332s The following NEW packages will be installed: 332s autoconf automake autopoint autotools-dev binutils-mingw-w64-i686 332s binutils-mingw-w64-x86-64 build-essential cargo cargo-1.80 cmake cmake-data 332s cpp cpp-14 cpp-14-s390x-linux-gnu cpp-s390x-linux-gnu debhelper debugedit 332s dh-autoreconf dh-python dh-strip-nondeterminism dwz fontconfig-config 332s fonts-dejavu-core fonts-dejavu-mono g++ g++-14 g++-14-s390x-linux-gnu 332s g++-s390x-linux-gnu gcc gcc-14 gcc-14-s390x-linux-gnu gcc-s390x-linux-gnu 332s gettext intltool-debian libarchive-zip-perl libasan8 libbrotli-dev 332s libbz2-dev libcc1-0 libdebhelper-perl libexpat1-dev 332s libfile-stripnondeterminism-perl libfontconfig-dev libfontconfig1 332s libfreetype-dev libfreetype6 libgcc-14-dev libgit2-1.7 libgomp1 332s libhttp-parser2.9 libisl23 libitm1 libjsoncpp25 libmpc3 libpfm4 libpkgconf3 332s libpng-dev libpython3-all-dev libpython3-dev libpython3.12-dev libpython3.13 332s libpython3.13-dev libpython3.13-minimal libpython3.13-stdlib librhash0 332s librust-ab-glyph-dev librust-ab-glyph-rasterizer+libm-dev 332s librust-ab-glyph-rasterizer-dev librust-addr2line-dev librust-adler-dev 332s librust-ahash-dev librust-aho-corasick-dev librust-allocator-api2-dev 332s librust-anes-dev librust-anstream-dev librust-anstyle-dev 332s librust-anstyle-parse-dev librust-anstyle-query-dev librust-anyhow-dev 332s librust-approx-dev librust-arbitrary-dev librust-array-init-dev 332s librust-arrayvec-dev librust-async-attributes-dev librust-async-channel-dev 332s librust-async-executor-dev librust-async-fs-dev 332s librust-async-global-executor-dev librust-async-io-dev 332s librust-async-lock-dev librust-async-net-dev librust-async-process-dev 332s librust-async-signal-dev librust-async-std-dev librust-async-task-dev 332s librust-atomic-dev librust-atomic-waker-dev librust-autocfg-dev 332s librust-backtrace-dev librust-base64-dev librust-bit-set+std-dev 332s librust-bit-set-dev librust-bit-vec-dev librust-bitflags-1-dev 332s librust-bitflags-dev librust-bitvec-dev librust-blobby-dev 332s librust-block-buffer-dev librust-blocking-dev librust-bstr-dev 332s librust-bumpalo-dev librust-bytecheck-derive-dev librust-bytecheck-dev 332s librust-bytemuck-derive-dev librust-bytemuck-dev librust-byteorder-dev 332s librust-bytes-dev librust-cast-dev librust-cc-dev librust-cfg-if-0.1-dev 332s librust-cfg-if-dev librust-chrono-dev librust-chrono-tz-build-dev 332s librust-chrono-tz-dev librust-ciborium-dev librust-ciborium-io-dev 332s librust-ciborium-ll-dev librust-clap-builder-dev librust-clap-derive-dev 332s librust-clap-dev librust-clap-lex-dev librust-cmake-dev 332s librust-color-quant-dev librust-colorchoice-dev 332s librust-compiler-builtins+core-dev 332s librust-compiler-builtins+rustc-dep-of-std-dev librust-compiler-builtins-dev 332s librust-concurrent-queue-dev librust-const-cstr-dev librust-const-oid-dev 332s librust-const-random-dev librust-const-random-macro-dev 332s librust-convert-case-dev librust-core-maths-dev librust-cpp-demangle-dev 332s librust-cpufeatures-dev librust-crc32fast-dev librust-criterion-dev 332s librust-critical-section-dev librust-crossbeam-deque-dev 332s librust-crossbeam-epoch+std-dev librust-crossbeam-epoch-dev 332s librust-crossbeam-utils-dev librust-crunchy-dev librust-crypto-common-dev 332s librust-csv-core-dev librust-csv-dev librust-ctor-dev librust-deranged-dev 332s librust-derive-arbitrary-dev librust-derive-more-0.99-dev librust-digest-dev 332s librust-dirs-next-dev librust-dirs-sys-next-dev librust-dlib-dev 332s librust-either-dev librust-env-logger-dev librust-equivalent-dev 332s librust-erased-serde-dev librust-errno-dev librust-eui48-dev 332s librust-event-listener-dev librust-event-listener-strategy-dev 332s librust-eyre+default-dev librust-eyre-dev librust-fallible-iterator-dev 332s librust-fancy-regex-dev librust-fastrand-dev librust-flate2-dev 332s librust-float-ord-dev librust-fnv-dev librust-font-kit-dev 332s librust-freetype-dev librust-freetype-sys-dev librust-funty-dev 332s librust-futures-channel-dev librust-futures-core-dev librust-futures-dev 332s librust-futures-executor-dev librust-futures-io-dev librust-futures-lite-dev 332s librust-futures-macro-dev librust-futures-sink-dev librust-futures-task-dev 332s librust-futures-util-dev librust-generic-array-dev librust-geo-types-dev 332s librust-getrandom-dev librust-ghost-dev librust-gif-dev librust-gimli-dev 332s librust-half-dev librust-hashbrown-dev librust-heck-dev librust-hmac-dev 332s librust-humantime-dev librust-iana-time-zone-dev librust-image-dev 332s librust-indenter-dev librust-indexmap-dev librust-indoc-dev 332s librust-inventory-dev librust-is-terminal-dev librust-itertools-dev 332s librust-itoa-dev librust-jobserver-dev librust-jpeg-decoder-dev 332s librust-js-sys-dev librust-kv-log-macro-dev librust-lazy-static-dev 332s librust-libc-dev librust-libloading-dev librust-libm-dev 332s librust-libwebp-sys-dev librust-libz-sys-dev librust-linux-raw-sys-dev 332s librust-lock-api-dev librust-log-dev librust-md-5-dev librust-md5-asm-dev 332s librust-memchr-dev librust-memmap2-dev librust-memoffset-dev 332s librust-miniz-oxide-dev librust-mio-dev librust-no-panic-dev 332s librust-num-bigint-dev librust-num-complex-dev librust-num-conv-dev 332s librust-num-cpus-dev librust-num-integer-dev librust-num-rational-dev 332s librust-num-threads-dev librust-num-traits-dev librust-object-dev 332s librust-once-cell-dev librust-oorandom-dev librust-owned-ttf-parser-dev 332s librust-owning-ref-dev librust-parking-dev librust-parking-lot-core-dev 332s librust-parking-lot-dev librust-parse-zoneinfo-dev 332s librust-pathfinder-geometry-dev librust-pathfinder-simd-dev 332s librust-phf+uncased-dev librust-phf-codegen-dev librust-phf-dev 332s librust-phf-generator-dev librust-phf-shared+uncased-dev 332s librust-phf-shared-dev librust-pin-project-lite-dev librust-pin-utils-dev 332s librust-pkg-config-dev librust-plotters-backend-dev 332s librust-plotters-bitmap-dev librust-plotters-dev librust-plotters-svg-dev 332s librust-png-dev librust-polling-dev librust-portable-atomic-dev 332s librust-postgres-derive-dev librust-postgres-protocol-dev 332s librust-postgres-types-dev librust-powerfmt-dev librust-powerfmt-macros-dev 332s librust-ppv-lite86-dev librust-proc-macro2-dev librust-proptest-dev 332s librust-ptr-meta-derive-dev librust-ptr-meta-dev 332s librust-pure-rust-locales-dev librust-pyo3-build-config-dev librust-pyo3-dev 332s librust-pyo3-ffi-dev librust-pyo3-macros-backend-dev librust-pyo3-macros-dev 332s librust-python3-dll-a-dev librust-qoi-dev librust-quick-error-dev 332s librust-quickcheck-dev librust-quote-dev librust-radium-dev 332s librust-rand-chacha-dev librust-rand-core+getrandom-dev 332s librust-rand-core+serde-dev librust-rand-core+std-dev librust-rand-core-dev 332s librust-rand-dev librust-rand-xorshift-dev librust-rayon-core-dev 332s librust-rayon-dev librust-regex-automata-dev librust-regex-dev 332s librust-regex-syntax-dev librust-rend-dev librust-rkyv-derive-dev 332s librust-rkyv-dev librust-rust-decimal-dev librust-rustc-demangle-dev 332s librust-rustc-hash-dev librust-rustc-std-workspace-core-dev 332s librust-rustc-version-dev librust-rustix-dev 332s librust-rusty-fork+wait-timeout-dev librust-rusty-fork-dev 332s librust-ruzstd-dev librust-ryu-dev librust-same-file-dev 332s librust-scopeguard-dev librust-seahash-dev librust-semver-dev 332s librust-serde-derive-dev librust-serde-dev librust-serde-fmt-dev 332s librust-serde-json-dev librust-serde-test-dev librust-sha1-asm-dev 332s librust-sha1-dev librust-sha2-asm-dev librust-sha2-dev librust-shlex-dev 332s librust-signal-hook-registry-dev librust-simdutf8-dev librust-siphasher-dev 332s librust-slab-dev librust-slog-dev librust-smallvec-dev librust-smol-dev 332s librust-smol-str-dev librust-socket2-dev librust-spin-dev 332s librust-stable-deref-trait-dev librust-static-assertions-dev 332s librust-stringprep-dev librust-strsim-dev librust-subtle-dev 332s librust-sval-buffer-dev librust-sval-derive-dev librust-sval-dev 332s librust-sval-dynamic-dev librust-sval-fmt-dev librust-sval-ref-dev 332s librust-sval-serde-dev librust-syn-1-dev librust-syn-dev librust-tap-dev 332s librust-target-lexicon-dev librust-tempfile-dev librust-termcolor-dev 332s librust-terminal-size-dev librust-tiff-dev librust-time-core-dev 332s librust-time-dev librust-time-macros-dev librust-tiny-keccak-dev 332s librust-tinytemplate-dev librust-tinyvec+tinyvec-macros-dev 332s librust-tinyvec-dev librust-tinyvec-macros-dev librust-tokio-dev 332s librust-tokio-macros-dev librust-tracing-attributes-dev 332s librust-tracing-core-dev librust-tracing-dev librust-traitobject-dev 332s librust-ttf-parser-dev librust-twox-hash-dev librust-typemap-dev 332s librust-typenum-dev librust-unarray-dev librust-uncased-dev 332s librust-unicase-dev librust-unicode-bidi-dev librust-unicode-ident-dev 332s librust-unicode-normalization-dev librust-unicode-segmentation-dev 332s librust-unicode-width-dev librust-unindent-dev librust-unsafe-any-dev 332s librust-utf8parse-dev librust-uuid-dev librust-valuable-derive-dev 332s librust-valuable-dev librust-value-bag-dev librust-value-bag-serde1-dev 332s librust-value-bag-sval2-dev librust-version-check-dev 332s librust-wait-timeout-dev librust-walkdir-dev 332s librust-wasm-bindgen+default-dev librust-wasm-bindgen+spans-dev 332s librust-wasm-bindgen-backend-dev librust-wasm-bindgen-dev 332s librust-wasm-bindgen-macro+spans-dev librust-wasm-bindgen-macro-dev 332s librust-wasm-bindgen-macro-support+spans-dev 332s librust-wasm-bindgen-macro-support-dev librust-wasm-bindgen-shared-dev 332s librust-web-sys-dev librust-webp-dev librust-weezl-dev librust-winapi-dev 332s librust-winapi-i686-pc-windows-gnu-dev librust-winapi-util-dev 332s librust-winapi-x86-64-pc-windows-gnu-dev librust-wyz-dev 332s librust-yeslogic-fontconfig-sys-dev librust-zerocopy-derive-dev 332s librust-zerocopy-dev librust-zeroize-derive-dev librust-zeroize-dev 332s libsharpyuv-dev libsharpyuv0 libstd-rust-1.80 libstd-rust-1.80-dev 332s libstdc++-14-dev libtool libubsan1 libwebp-dev libwebp7 libwebpdecoder3 332s libwebpdemux2 libwebpmux3 llvm llvm-19 llvm-19-linker-tools llvm-19-runtime 332s llvm-runtime m4 pkg-config pkgconf pkgconf-bin po-debconf 332s pybuild-plugin-autopkgtest pybuild-plugin-pyproject python3-all 332s python3-build python3-dateutil python3-hypothesis python3-iniconfig 332s python3-installer python3-packaging python3-pluggy python3-pyproject-hooks 332s python3-pytest python3-regex python3-semantic-version 332s python3-setuptools-rust python3-sortedcontainers python3-tiktoken 332s python3-toml python3-wheel python3.12-dev python3.13 python3.13-minimal 332s rustc rustc-1.80 uuid-dev zlib1g-dev 333s 0 upgraded, 470 newly installed, 0 to remove and 0 not upgraded. 333s Need to get 230 MB of archives. 333s After this operation, 981 MB of additional disk space will be used. 333s Get:1 http://ftpmaster.internal/ubuntu plucky/main s390x libpython3.13-minimal s390x 3.13.0-2 [877 kB] 333s Get:2 http://ftpmaster.internal/ubuntu plucky/main s390x python3.13-minimal s390x 3.13.0-2 [2172 kB] 333s Get:3 http://ftpmaster.internal/ubuntu plucky/main s390x m4 s390x 1.4.19-4build1 [256 kB] 333s Get:4 http://ftpmaster.internal/ubuntu plucky/main s390x autoconf all 2.72-3 [382 kB] 333s Get:5 http://ftpmaster.internal/ubuntu plucky/main s390x autotools-dev all 20220109.1 [44.9 kB] 333s Get:6 http://ftpmaster.internal/ubuntu plucky/main s390x automake all 1:1.16.5-1.3ubuntu1 [558 kB] 333s Get:7 http://ftpmaster.internal/ubuntu plucky/main s390x autopoint all 0.22.5-2 [616 kB] 333s Get:8 http://ftpmaster.internal/ubuntu plucky/main s390x libisl23 s390x 0.27-1 [704 kB] 333s Get:9 http://ftpmaster.internal/ubuntu plucky/main s390x libmpc3 s390x 1.3.1-1build2 [57.8 kB] 333s Get:10 http://ftpmaster.internal/ubuntu plucky/main s390x cpp-14-s390x-linux-gnu s390x 14.2.0-8ubuntu1 [9570 kB] 333s Get:11 http://ftpmaster.internal/ubuntu plucky/main s390x cpp-14 s390x 14.2.0-8ubuntu1 [1026 B] 333s Get:12 http://ftpmaster.internal/ubuntu plucky/main s390x cpp-s390x-linux-gnu s390x 4:14.1.0-2ubuntu1 [5452 B] 333s Get:13 http://ftpmaster.internal/ubuntu plucky/main s390x cpp s390x 4:14.1.0-2ubuntu1 [22.4 kB] 333s Get:14 http://ftpmaster.internal/ubuntu plucky/main s390x libcc1-0 s390x 14.2.0-8ubuntu1 [50.6 kB] 333s Get:15 http://ftpmaster.internal/ubuntu plucky/main s390x libgomp1 s390x 14.2.0-8ubuntu1 [151 kB] 333s Get:16 http://ftpmaster.internal/ubuntu plucky/main s390x libitm1 s390x 14.2.0-8ubuntu1 [30.9 kB] 333s Get:17 http://ftpmaster.internal/ubuntu plucky/main s390x libasan8 s390x 14.2.0-8ubuntu1 [2963 kB] 333s Get:18 http://ftpmaster.internal/ubuntu plucky/main s390x libubsan1 s390x 14.2.0-8ubuntu1 [1184 kB] 333s Get:19 http://ftpmaster.internal/ubuntu plucky/main s390x libgcc-14-dev s390x 14.2.0-8ubuntu1 [1037 kB] 333s Get:20 http://ftpmaster.internal/ubuntu plucky/main s390x gcc-14-s390x-linux-gnu s390x 14.2.0-8ubuntu1 [18.7 MB] 334s Get:21 http://ftpmaster.internal/ubuntu plucky/main s390x gcc-14 s390x 14.2.0-8ubuntu1 [518 kB] 334s Get:22 http://ftpmaster.internal/ubuntu plucky/main s390x gcc-s390x-linux-gnu s390x 4:14.1.0-2ubuntu1 [1204 B] 334s Get:23 http://ftpmaster.internal/ubuntu plucky/main s390x gcc s390x 4:14.1.0-2ubuntu1 [4996 B] 334s Get:24 http://ftpmaster.internal/ubuntu plucky/main s390x libstdc++-14-dev s390x 14.2.0-8ubuntu1 [2608 kB] 334s Get:25 http://ftpmaster.internal/ubuntu plucky/main s390x g++-14-s390x-linux-gnu s390x 14.2.0-8ubuntu1 [11.0 MB] 334s Get:26 http://ftpmaster.internal/ubuntu plucky/main s390x g++-14 s390x 14.2.0-8ubuntu1 [19.9 kB] 334s Get:27 http://ftpmaster.internal/ubuntu plucky/main s390x g++-s390x-linux-gnu s390x 4:14.1.0-2ubuntu1 [956 B] 334s Get:28 http://ftpmaster.internal/ubuntu plucky/main s390x g++ s390x 4:14.1.0-2ubuntu1 [1076 B] 334s Get:29 http://ftpmaster.internal/ubuntu plucky/main s390x build-essential s390x 12.10ubuntu1 [4930 B] 334s Get:30 http://ftpmaster.internal/ubuntu plucky/main s390x libhttp-parser2.9 s390x 2.9.4-6build1 [24.7 kB] 334s Get:31 http://ftpmaster.internal/ubuntu plucky/main s390x libgit2-1.7 s390x 1.7.2+ds-1ubuntu3 [553 kB] 334s Get:32 http://ftpmaster.internal/ubuntu plucky/main s390x libstd-rust-1.80 s390x 1.80.1+dfsg0ubuntu1-0ubuntu1 [26.1 MB] 335s Get:33 http://ftpmaster.internal/ubuntu plucky/main s390x libstd-rust-1.80-dev s390x 1.80.1+dfsg0ubuntu1-0ubuntu1 [43.6 MB] 337s Get:34 http://ftpmaster.internal/ubuntu plucky/main s390x rustc-1.80 s390x 1.80.1+dfsg0ubuntu1-0ubuntu1 [3730 kB] 337s Get:35 http://ftpmaster.internal/ubuntu plucky/main s390x cargo-1.80 s390x 1.80.1+dfsg0ubuntu1-0ubuntu1 [6792 kB] 337s Get:36 http://ftpmaster.internal/ubuntu plucky/main s390x libjsoncpp25 s390x 1.9.5-6build1 [82.5 kB] 337s Get:37 http://ftpmaster.internal/ubuntu plucky/main s390x librhash0 s390x 1.4.3-3build1 [133 kB] 337s Get:38 http://ftpmaster.internal/ubuntu plucky/main s390x cmake-data all 3.30.3-1 [2246 kB] 337s Get:39 http://ftpmaster.internal/ubuntu plucky/main s390x cmake s390x 3.30.3-1 [12.3 MB] 338s Get:40 http://ftpmaster.internal/ubuntu plucky/main s390x libdebhelper-perl all 13.20ubuntu1 [94.2 kB] 338s Get:41 http://ftpmaster.internal/ubuntu plucky/main s390x libtool all 2.4.7-8 [166 kB] 338s Get:42 http://ftpmaster.internal/ubuntu plucky/main s390x dh-autoreconf all 20 [16.1 kB] 338s Get:43 http://ftpmaster.internal/ubuntu plucky/main s390x libarchive-zip-perl all 1.68-1 [90.2 kB] 338s Get:44 http://ftpmaster.internal/ubuntu plucky/main s390x libfile-stripnondeterminism-perl all 1.14.0-1 [20.1 kB] 338s Get:45 http://ftpmaster.internal/ubuntu plucky/main s390x dh-strip-nondeterminism all 1.14.0-1 [5058 B] 338s Get:46 http://ftpmaster.internal/ubuntu plucky/main s390x debugedit s390x 1:5.1-1 [49.9 kB] 338s Get:47 http://ftpmaster.internal/ubuntu plucky/main s390x dwz s390x 0.15-1build6 [122 kB] 338s Get:48 http://ftpmaster.internal/ubuntu plucky/main s390x gettext s390x 0.22.5-2 [996 kB] 338s Get:49 http://ftpmaster.internal/ubuntu plucky/main s390x intltool-debian all 0.35.0+20060710.6 [23.2 kB] 338s Get:50 http://ftpmaster.internal/ubuntu plucky/main s390x po-debconf all 1.0.21+nmu1 [233 kB] 338s Get:51 http://ftpmaster.internal/ubuntu plucky/main s390x debhelper all 13.20ubuntu1 [893 kB] 338s Get:52 http://ftpmaster.internal/ubuntu plucky/universe s390x dh-python all 6.20241024 [112 kB] 338s Get:53 http://ftpmaster.internal/ubuntu plucky/main s390x fonts-dejavu-mono all 2.37-8 [502 kB] 338s Get:54 http://ftpmaster.internal/ubuntu plucky/main s390x fonts-dejavu-core all 2.37-8 [835 kB] 338s Get:55 http://ftpmaster.internal/ubuntu plucky/main s390x fontconfig-config s390x 2.15.0-1.1ubuntu2 [37.4 kB] 338s Get:56 http://ftpmaster.internal/ubuntu plucky/main s390x libbrotli-dev s390x 1.1.0-2build3 [395 kB] 338s Get:57 http://ftpmaster.internal/ubuntu plucky/main s390x libbz2-dev s390x 1.0.8-6 [39.1 kB] 338s Get:58 http://ftpmaster.internal/ubuntu plucky/main s390x libexpat1-dev s390x 2.6.4-1 [146 kB] 338s Get:59 http://ftpmaster.internal/ubuntu plucky/main s390x libfreetype6 s390x 2.13.3+dfsg-1 [431 kB] 338s Get:60 http://ftpmaster.internal/ubuntu plucky/main s390x libfontconfig1 s390x 2.15.0-1.1ubuntu2 [150 kB] 338s Get:61 http://ftpmaster.internal/ubuntu plucky/main s390x zlib1g-dev s390x 1:1.3.dfsg+really1.3.1-1ubuntu1 [898 kB] 338s Get:62 http://ftpmaster.internal/ubuntu plucky/main s390x libpng-dev s390x 1.6.44-2 [279 kB] 338s Get:63 http://ftpmaster.internal/ubuntu plucky/main s390x libfreetype-dev s390x 2.13.3+dfsg-1 [605 kB] 338s Get:64 http://ftpmaster.internal/ubuntu plucky/main s390x uuid-dev s390x 2.40.2-1ubuntu1 [52.4 kB] 338s Get:65 http://ftpmaster.internal/ubuntu plucky/main s390x libpkgconf3 s390x 1.8.1-4 [31.2 kB] 338s Get:66 http://ftpmaster.internal/ubuntu plucky/main s390x pkgconf-bin s390x 1.8.1-4 [21.5 kB] 338s Get:67 http://ftpmaster.internal/ubuntu plucky/main s390x pkgconf s390x 1.8.1-4 [16.7 kB] 338s Get:68 http://ftpmaster.internal/ubuntu plucky/main s390x libfontconfig-dev s390x 2.15.0-1.1ubuntu2 [172 kB] 338s Get:69 http://ftpmaster.internal/ubuntu plucky/main s390x libpython3.12-dev s390x 3.12.7-3 [5838 kB] 338s Get:70 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x libpython3-dev s390x 3.12.7-1 [10.3 kB] 338s Get:71 http://ftpmaster.internal/ubuntu plucky/main s390x libpython3.13-stdlib s390x 3.13.0-2 [2086 kB] 338s Get:72 http://ftpmaster.internal/ubuntu plucky/main s390x libpython3.13 s390x 3.13.0-2 [2477 kB] 339s Get:73 http://ftpmaster.internal/ubuntu plucky/main s390x libpython3.13-dev s390x 3.13.0-2 [5586 kB] 339s Get:74 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x libpython3-all-dev s390x 3.12.7-1 [918 B] 339s Get:75 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ab-glyph-rasterizer-dev s390x 0.1.7-1 [12.2 kB] 339s Get:76 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-libm-dev s390x 0.2.8-1 [101 kB] 339s Get:77 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ab-glyph-rasterizer+libm-dev s390x 0.1.7-1 [1064 B] 339s Get:78 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-core-maths-dev s390x 0.1.0-2 [7948 B] 339s Get:79 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ttf-parser-dev s390x 0.24.1-1 [148 kB] 339s Get:80 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-owned-ttf-parser-dev s390x 0.24.0-1 [129 kB] 339s Get:81 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ab-glyph-dev s390x 0.2.28-1 [20.7 kB] 339s Get:82 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-cfg-if-dev s390x 1.0.0-1 [10.5 kB] 339s Get:83 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-cpp-demangle-dev s390x 0.4.0-1 [66.1 kB] 339s Get:84 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-fallible-iterator-dev s390x 0.3.0-2 [20.3 kB] 339s Get:85 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-unicode-ident-dev s390x 1.0.13-1 [38.5 kB] 339s Get:86 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-proc-macro2-dev s390x 1.0.86-1 [44.8 kB] 339s Get:87 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-quote-dev s390x 1.0.37-1 [29.5 kB] 339s Get:88 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-syn-dev s390x 2.0.85-1 [219 kB] 339s Get:89 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-derive-arbitrary-dev s390x 1.3.2-1 [12.3 kB] 339s Get:90 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-arbitrary-dev s390x 1.3.2-1 [31.4 kB] 339s Get:91 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-equivalent-dev s390x 1.0.1-1 [8240 B] 339s Get:92 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-critical-section-dev s390x 1.1.3-1 [20.5 kB] 339s Get:93 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-serde-derive-dev s390x 1.0.210-1 [50.1 kB] 339s Get:94 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-serde-dev s390x 1.0.210-2 [66.4 kB] 339s Get:95 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-portable-atomic-dev s390x 1.9.0-4 [124 kB] 339s Get:96 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rustc-std-workspace-core-dev s390x 1.0.0-1 [3020 B] 339s Get:97 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-libc-dev s390x 0.2.161-1 [379 kB] 339s Get:98 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-getrandom-dev s390x 0.2.12-1 [36.4 kB] 339s Get:99 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-smallvec-dev s390x 1.13.2-1 [35.5 kB] 339s Get:100 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-parking-lot-core-dev s390x 0.9.10-1 [32.6 kB] 339s Get:101 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-once-cell-dev s390x 1.20.2-1 [31.9 kB] 339s Get:102 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-crunchy-dev s390x 0.2.2-1 [5340 B] 339s Get:103 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tiny-keccak-dev s390x 2.0.2-1 [20.9 kB] 339s Get:104 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-const-random-macro-dev s390x 0.1.16-2 [10.5 kB] 339s Get:105 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-const-random-dev s390x 0.1.17-2 [8590 B] 339s Get:106 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-version-check-dev s390x 0.9.5-1 [16.9 kB] 339s Get:107 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-byteorder-dev s390x 1.5.0-1 [22.4 kB] 339s Get:108 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-zerocopy-derive-dev s390x 0.7.32-2 [29.7 kB] 339s Get:109 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-zerocopy-dev s390x 0.7.32-1 [116 kB] 339s Get:110 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ahash-dev all 0.8.11-8 [37.9 kB] 339s Get:111 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-allocator-api2-dev s390x 0.2.16-1 [54.8 kB] 339s Get:112 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-compiler-builtins-dev s390x 0.1.101-1 [156 kB] 339s Get:113 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-either-dev s390x 1.13.0-1 [20.2 kB] 339s Get:114 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-crossbeam-utils-dev s390x 0.8.19-1 [41.1 kB] 339s Get:115 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-crossbeam-epoch-dev s390x 0.9.18-1 [42.3 kB] 339s Get:116 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-crossbeam-epoch+std-dev s390x 0.9.18-1 [1128 B] 339s Get:117 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-crossbeam-deque-dev s390x 0.8.5-1 [22.4 kB] 339s Get:118 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rayon-core-dev s390x 1.12.1-1 [63.7 kB] 340s Get:119 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rayon-dev s390x 1.10.0-1 [149 kB] 340s Get:120 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-hashbrown-dev s390x 0.14.5-5 [110 kB] 340s Get:121 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-indexmap-dev s390x 2.2.6-1 [66.7 kB] 340s Get:122 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-stable-deref-trait-dev s390x 1.2.0-1 [9794 B] 340s Get:123 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-gimli-dev s390x 0.28.1-2 [209 kB] 340s Get:124 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-memmap2-dev s390x 0.9.3-1 [30.8 kB] 340s Get:125 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-crc32fast-dev s390x 1.4.2-1 [39.8 kB] 340s Get:126 http://ftpmaster.internal/ubuntu plucky/main s390x pkg-config s390x 1.8.1-4 [7362 B] 340s Get:127 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-pkg-config-dev s390x 0.3.27-1 [21.5 kB] 340s Get:128 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-libz-sys-dev s390x 1.1.20-1 [19.7 kB] 340s Get:129 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-adler-dev s390x 1.0.2-2 [15.3 kB] 340s Get:130 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-miniz-oxide-dev s390x 0.7.1-1 [51.5 kB] 340s Get:131 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-flate2-dev s390x 1.0.34-1 [94.5 kB] 340s Get:132 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-sval-derive-dev s390x 2.6.1-2 [11.0 kB] 340s Get:133 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-sval-dev s390x 2.6.1-2 [28.0 kB] 340s Get:134 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-sval-ref-dev s390x 2.6.1-1 [8942 B] 340s Get:135 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-erased-serde-dev s390x 0.3.31-1 [22.7 kB] 340s Get:136 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-serde-fmt-dev all 1.0.3-3 [6956 B] 340s Get:137 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-syn-1-dev s390x 1.0.109-2 [188 kB] 340s Get:138 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-no-panic-dev s390x 0.1.13-1 [11.3 kB] 340s Get:139 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-itoa-dev s390x 1.0.9-1 [13.1 kB] 340s Get:140 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ryu-dev s390x 1.0.15-1 [41.7 kB] 340s Get:141 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-serde-json-dev s390x 1.0.128-1 [128 kB] 340s Get:142 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-serde-test-dev s390x 1.0.171-1 [20.6 kB] 340s Get:143 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-value-bag-serde1-dev s390x 1.9.0-1 [7820 B] 340s Get:144 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-sval-buffer-dev s390x 2.6.1-1 [16.8 kB] 340s Get:145 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-sval-dynamic-dev s390x 2.6.1-1 [9542 B] 340s Get:146 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-sval-fmt-dev s390x 2.6.1-1 [12.0 kB] 340s Get:147 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-sval-serde-dev s390x 2.6.1-1 [13.2 kB] 340s Get:148 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-value-bag-sval2-dev s390x 1.9.0-1 [7862 B] 340s Get:149 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-value-bag-dev s390x 1.9.0-1 [37.6 kB] 340s Get:150 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-log-dev s390x 0.4.22-1 [43.0 kB] 340s Get:151 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-memchr-dev s390x 2.7.4-1 [71.8 kB] 340s Get:152 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ppv-lite86-dev s390x 0.2.16-1 [21.9 kB] 340s Get:153 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rand-core-dev s390x 0.6.4-2 [23.8 kB] 340s Get:154 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rand-chacha-dev s390x 0.3.1-2 [16.9 kB] 340s Get:155 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rand-core+getrandom-dev s390x 0.6.4-2 [1054 B] 340s Get:156 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rand-core+serde-dev s390x 0.6.4-2 [1108 B] 340s Get:157 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rand-core+std-dev s390x 0.6.4-2 [1052 B] 340s Get:158 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rand-dev s390x 0.8.5-1 [77.5 kB] 340s Get:159 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-unicode-segmentation-dev s390x 1.11.0-1 [74.2 kB] 340s Get:160 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-convert-case-dev s390x 0.6.0-2 [19.4 kB] 340s Get:161 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-semver-dev s390x 1.0.23-1 [30.6 kB] 340s Get:162 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rustc-version-dev s390x 0.4.0-1 [13.8 kB] 340s Get:163 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-derive-more-0.99-dev s390x 0.99.18-2 [49.9 kB] 340s Get:164 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-cfg-if-0.1-dev s390x 0.1.10-3 [10.5 kB] 340s Get:165 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-blobby-dev s390x 0.3.1-1 [11.3 kB] 340s Get:166 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-typenum-dev s390x 1.17.0-2 [41.2 kB] 340s Get:167 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-zeroize-derive-dev s390x 1.4.2-1 [12.7 kB] 340s Get:168 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-zeroize-dev s390x 1.8.1-1 [21.6 kB] 340s Get:169 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-generic-array-dev s390x 0.14.7-1 [16.9 kB] 340s Get:170 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-block-buffer-dev s390x 0.10.2-2 [12.2 kB] 340s Get:171 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-const-oid-dev s390x 0.9.3-1 [40.9 kB] 340s Get:172 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-crypto-common-dev s390x 0.1.6-1 [10.5 kB] 340s Get:173 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-subtle-dev s390x 2.6.1-1 [16.1 kB] 340s Get:174 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-digest-dev s390x 0.10.7-2 [20.9 kB] 340s Get:175 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-static-assertions-dev s390x 1.1.0-1 [19.0 kB] 340s Get:176 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-twox-hash-dev s390x 1.6.3-1 [21.6 kB] 340s Get:177 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ruzstd-dev s390x 0.5.0-1 [44.6 kB] 340s Get:178 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-object-dev s390x 0.32.2-1 [228 kB] 340s Get:179 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rustc-demangle-dev s390x 0.1.21-1 [27.7 kB] 340s Get:180 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-addr2line-dev s390x 0.21.0-2 [36.4 kB] 340s Get:181 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-aho-corasick-dev s390x 1.1.3-1 [146 kB] 340s Get:182 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bitflags-1-dev s390x 1.3.2-5 [25.3 kB] 340s Get:183 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-anes-dev s390x 0.1.6-1 [21.1 kB] 340s Get:184 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-anstyle-dev s390x 1.0.8-1 [16.7 kB] 340s Get:185 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-arrayvec-dev s390x 0.7.4-2 [29.9 kB] 340s Get:186 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-utf8parse-dev s390x 0.2.1-1 [15.0 kB] 340s Get:187 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-anstyle-parse-dev s390x 0.2.1-1 [17.1 kB] 340s Get:188 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-anstyle-query-dev s390x 1.0.0-1 [9768 B] 340s Get:189 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-colorchoice-dev s390x 1.0.0-1 [8338 B] 340s Get:190 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-anstream-dev s390x 0.6.15-1 [25.7 kB] 340s Get:191 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-jobserver-dev s390x 0.1.32-1 [29.1 kB] 341s Get:192 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-shlex-dev s390x 1.3.0-1 [20.1 kB] 341s Get:193 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-cc-dev s390x 1.1.14-1 [73.6 kB] 341s Get:194 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-backtrace-dev s390x 0.3.69-2 [69.9 kB] 341s Get:195 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-anyhow-dev s390x 1.0.86-1 [44.3 kB] 341s Get:196 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bytecheck-derive-dev s390x 0.6.12-1 [7086 B] 341s Get:197 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ptr-meta-derive-dev s390x 0.1.4-1 [3964 B] 341s Get:198 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ptr-meta-dev s390x 0.1.4-1 [7344 B] 341s Get:199 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-simdutf8-dev s390x 0.1.4-4 [27.2 kB] 341s Get:200 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bytemuck-derive-dev s390x 1.5.0-2 [18.7 kB] 341s Get:201 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bytemuck-dev s390x 1.14.0-1 [42.7 kB] 341s Get:202 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-atomic-dev s390x 0.6.0-1 [15.5 kB] 341s Get:203 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-md5-asm-dev s390x 0.5.0-2 [7516 B] 341s Get:204 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-md-5-dev s390x 0.10.6-1 [17.5 kB] 341s Get:205 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-cpufeatures-dev s390x 0.2.11-1 [14.9 kB] 341s Get:206 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-sha1-asm-dev s390x 0.5.1-2 [8060 B] 341s Get:207 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-sha1-dev s390x 0.10.6-1 [16.0 kB] 341s Get:208 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-slog-dev s390x 2.7.0-1 [44.0 kB] 341s Get:209 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-uuid-dev s390x 1.10.0-1 [44.2 kB] 341s Get:210 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bytecheck-dev s390x 0.6.12-1 [10.2 kB] 341s Get:211 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-autocfg-dev s390x 1.1.0-1 [15.2 kB] 341s Get:212 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-num-traits-dev s390x 0.2.19-2 [46.2 kB] 341s Get:213 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-funty-dev s390x 2.0.0-1 [13.8 kB] 341s Get:214 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-radium-dev s390x 1.1.0-1 [14.9 kB] 341s Get:215 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tap-dev s390x 1.0.1-1 [12.7 kB] 341s Get:216 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-traitobject-dev s390x 0.1.0-1 [4540 B] 341s Get:217 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-unsafe-any-dev s390x 0.4.2-2 [4626 B] 341s Get:218 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-typemap-dev s390x 0.3.3-2 [6724 B] 341s Get:219 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-wyz-dev s390x 0.5.1-1 [19.7 kB] 341s Get:220 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bitvec-dev s390x 1.0.1-1 [179 kB] 341s Get:221 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bytes-dev s390x 1.8.0-1 [56.9 kB] 341s Get:222 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rend-dev s390x 0.4.0-1 [10.3 kB] 341s Get:223 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rkyv-derive-dev s390x 0.7.44-1 [17.5 kB] 341s Get:224 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-seahash-dev s390x 4.1.0-1 [25.1 kB] 341s Get:225 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-smol-str-dev s390x 0.2.0-1 [15.2 kB] 341s Get:226 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tinyvec-dev s390x 1.6.0-2 [37.7 kB] 341s Get:227 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tinyvec-macros-dev s390x 0.1.0-1 [3852 B] 341s Get:228 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tinyvec+tinyvec-macros-dev s390x 1.6.0-2 [1126 B] 341s Get:229 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rkyv-dev s390x 0.7.44-1 [94.4 kB] 341s Get:230 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-num-complex-dev s390x 0.4.6-2 [30.8 kB] 341s Get:231 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-approx-dev s390x 0.5.1-1 [16.0 kB] 341s Get:232 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-array-init-dev s390x 2.0.1-1 [12.3 kB] 341s Get:233 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-attributes-dev all 1.1.2-6 [6756 B] 341s Get:234 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-concurrent-queue-dev s390x 2.5.0-4 [23.9 kB] 341s Get:235 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-parking-dev s390x 2.2.0-1 [11.6 kB] 341s Get:236 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-pin-project-lite-dev s390x 0.2.13-1 [30.2 kB] 341s Get:237 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-event-listener-dev all 5.3.1-8 [29.6 kB] 341s Get:238 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-event-listener-strategy-dev s390x 0.5.2-3 [12.6 kB] 341s Get:239 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-futures-core-dev s390x 0.3.30-1 [16.7 kB] 341s Get:240 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-channel-dev all 2.3.1-8 [13.1 kB] 341s Get:241 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-task-dev all 4.7.1-3 [29.4 kB] 341s Get:242 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-fastrand-dev s390x 2.1.1-1 [17.8 kB] 342s Get:243 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-futures-io-dev s390x 0.3.31-1 [11.2 kB] 342s Get:244 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-futures-lite-dev s390x 2.3.0-2 [38.6 kB] 342s Get:245 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-slab-dev s390x 0.4.9-1 [21.2 kB] 342s Get:246 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-executor-dev all 1.13.1-1 [18.7 kB] 342s Get:247 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-lock-dev all 3.4.0-4 [29.3 kB] 342s Get:248 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-atomic-waker-dev s390x 1.1.2-1 [14.3 kB] 342s Get:249 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tracing-attributes-dev s390x 0.1.27-1 [33.3 kB] 342s Get:250 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-valuable-derive-dev s390x 0.1.0-1 [5942 B] 342s Get:251 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-valuable-dev s390x 0.1.0-4 [23.5 kB] 342s Get:252 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tracing-core-dev s390x 0.1.32-1 [53.8 kB] 342s Get:253 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tracing-dev s390x 0.1.40-1 [69.5 kB] 342s Get:254 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-blocking-dev all 1.6.1-5 [17.5 kB] 342s Get:255 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-fs-dev all 2.1.2-4 [15.3 kB] 342s Get:256 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bitflags-dev s390x 2.6.0-1 [41.1 kB] 342s Get:257 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-compiler-builtins+core-dev s390x 0.1.101-1 [1092 B] 342s Get:258 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-compiler-builtins+rustc-dep-of-std-dev s390x 0.1.101-1 [1104 B] 342s Get:259 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-errno-dev s390x 0.3.8-1 [13.0 kB] 342s Get:260 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-linux-raw-sys-dev s390x 0.4.14-1 [138 kB] 342s Get:261 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rustix-dev s390x 0.38.37-1 [272 kB] 342s Get:262 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-polling-dev s390x 3.4.0-1 [47.8 kB] 342s Get:263 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-io-dev s390x 2.3.3-4 [41.0 kB] 342s Get:264 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-mio-dev s390x 1.0.2-2 [87.6 kB] 342s Get:265 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-owning-ref-dev s390x 0.4.1-1 [13.7 kB] 342s Get:266 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-scopeguard-dev s390x 1.2.0-1 [13.3 kB] 342s Get:267 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-lock-api-dev s390x 0.4.12-1 [22.9 kB] 342s Get:268 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-parking-lot-dev s390x 0.12.3-1 [38.7 kB] 342s Get:269 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-signal-hook-registry-dev s390x 1.4.0-1 [19.2 kB] 342s Get:270 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-socket2-dev s390x 0.5.7-1 [48.3 kB] 342s Get:271 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tokio-macros-dev s390x 2.4.0-2 [14.0 kB] 342s Get:272 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tokio-dev s390x 1.39.3-3 [561 kB] 342s Get:273 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-global-executor-dev s390x 2.4.1-5 [14.6 kB] 342s Get:274 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-net-dev all 2.0.0-4 [14.6 kB] 342s Get:275 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-signal-dev s390x 0.2.10-1 [16.0 kB] 342s Get:276 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-process-dev all 2.3.0-1 [21.2 kB] 342s Get:277 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-kv-log-macro-dev all 1.0.8-4 [7290 B] 342s Get:278 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-pin-utils-dev s390x 0.1.0-1 [9340 B] 342s Get:279 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-async-std-dev all 1.13.0-1 [170 kB] 342s Get:280 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-base64-dev s390x 0.21.7-1 [65.1 kB] 342s Get:281 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bit-vec-dev s390x 0.6.3-1 [21.1 kB] 342s Get:282 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bit-set-dev s390x 0.5.2-1 [15.7 kB] 342s Get:283 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bit-set+std-dev s390x 0.5.2-1 [1086 B] 342s Get:284 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-regex-syntax-dev s390x 0.8.2-1 [200 kB] 342s Get:285 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-regex-automata-dev s390x 0.4.7-1 [424 kB] 342s Get:286 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bstr-dev s390x 1.7.0-2build1 [271 kB] 342s Get:287 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-bumpalo-dev s390x 3.16.0-1 [75.7 kB] 342s Get:288 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-cast-dev s390x 0.3.0-1 [13.1 kB] 342s Get:289 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-iana-time-zone-dev s390x 0.1.60-1 [25.1 kB] 342s Get:290 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-wasm-bindgen-shared-dev s390x 0.2.87-1 [9088 B] 342s Get:291 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-wasm-bindgen-backend-dev s390x 0.2.87-1 [27.0 kB] 342s Get:292 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-wasm-bindgen-macro-support-dev s390x 0.2.87-1 [21.2 kB] 342s Get:293 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-wasm-bindgen-macro-dev s390x 0.2.87-1 [16.6 kB] 342s Get:294 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-wasm-bindgen-dev s390x 0.2.87-1 [157 kB] 342s Get:295 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-wasm-bindgen-macro-support+spans-dev s390x 0.2.87-1 [1074 B] 342s Get:296 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-wasm-bindgen-macro+spans-dev s390x 0.2.87-1 [1058 B] 342s Get:297 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-wasm-bindgen+spans-dev s390x 0.2.87-1 [1040 B] 342s Get:298 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-wasm-bindgen+default-dev s390x 0.2.87-1 [1048 B] 342s Get:299 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-js-sys-dev s390x 0.3.64-1 [71.9 kB] 342s Get:300 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-pure-rust-locales-dev s390x 0.8.1-1 [112 kB] 342s Get:301 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-chrono-dev s390x 0.4.38-2 [172 kB] 342s Get:302 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-regex-dev s390x 1.10.6-1 [199 kB] 342s Get:303 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-parse-zoneinfo-dev s390x 0.3.0-1 [71.0 kB] 342s Get:304 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-siphasher-dev s390x 0.3.10-1 [12.0 kB] 343s Get:305 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-phf-shared-dev s390x 0.11.2-1 [15.6 kB] 343s Get:306 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-phf-dev s390x 0.11.2-1 [21.6 kB] 343s Get:307 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-uncased-dev s390x 0.9.6-2 [12.2 kB] 343s Get:308 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-phf-shared+uncased-dev s390x 0.11.2-1 [1030 B] 343s Get:309 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-phf+uncased-dev s390x 0.11.2-1 [1030 B] 343s Get:310 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ciborium-io-dev s390x 0.2.2-1 [8180 B] 343s Get:311 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-half-dev s390x 1.8.2-4 [34.8 kB] 343s Get:312 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ciborium-ll-dev s390x 0.2.2-1 [15.8 kB] 343s Get:313 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ciborium-dev s390x 0.2.2-2 [32.6 kB] 343s Get:314 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-clap-lex-dev s390x 0.7.2-2 [14.3 kB] 343s Get:315 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-strsim-dev s390x 0.11.1-1 [15.9 kB] 343s Get:316 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-terminal-size-dev s390x 0.3.0-2 [12.6 kB] 343s Get:317 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-unicase-dev s390x 2.7.0-1 [19.4 kB] 343s Get:318 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-unicode-width-dev s390x 0.1.14-1 [196 kB] 343s Get:319 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-clap-builder-dev s390x 4.5.15-2 [135 kB] 343s Get:320 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-heck-dev s390x 0.4.1-1 [13.3 kB] 343s Get:321 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-clap-derive-dev s390x 4.5.13-2 [29.3 kB] 343s Get:322 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-clap-dev s390x 4.5.16-1 [52.3 kB] 343s Get:323 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-csv-core-dev s390x 0.1.11-1 [25.9 kB] 343s Get:324 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-csv-dev s390x 1.3.0-1 [729 kB] 343s Get:325 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-futures-sink-dev s390x 0.3.31-1 [10.1 kB] 343s Get:326 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-futures-channel-dev s390x 0.3.30-1 [31.8 kB] 343s Get:327 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-futures-task-dev s390x 0.3.30-1 [13.5 kB] 343s Get:328 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-futures-macro-dev s390x 0.3.30-1 [13.3 kB] 343s Get:329 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-futures-util-dev s390x 0.3.30-2 [127 kB] 343s Get:330 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-num-cpus-dev s390x 1.16.0-1 [18.1 kB] 343s Get:331 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-futures-executor-dev s390x 0.3.30-1 [19.8 kB] 343s Get:332 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-futures-dev s390x 0.3.30-2 [53.2 kB] 343s Get:333 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-is-terminal-dev s390x 0.4.13-1 [8266 B] 343s Get:334 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-itertools-dev s390x 0.10.5-1 [101 kB] 343s Get:335 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-oorandom-dev s390x 11.1.3-1 [11.3 kB] 343s Get:336 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-winapi-i686-pc-windows-gnu-dev s390x 0.4.0-1 [3652 B] 343s Get:337 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-winapi-x86-64-pc-windows-gnu-dev s390x 0.4.0-1 [3660 B] 343s Get:338 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-winapi-dev s390x 0.3.9-1 [953 kB] 343s Get:339 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-dirs-sys-next-dev s390x 0.1.1-1 [12.1 kB] 343s Get:340 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-dirs-next-dev s390x 2.0.0-1 [13.1 kB] 343s Get:341 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-float-ord-dev s390x 0.3.2-1 [9400 B] 343s Get:342 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-cmake-dev s390x 0.1.45-1 [16.0 kB] 343s Get:343 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-freetype-sys-dev s390x 0.13.1-1 [11.8 kB] 343s Get:344 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-freetype-dev s390x 0.7.0-4 [20.4 kB] 343s Get:345 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-spin-dev s390x 0.9.8-4 [33.4 kB] 343s Get:346 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-lazy-static-dev s390x 1.5.0-1 [14.2 kB] 343s Get:347 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-pathfinder-simd-dev s390x 0.5.2-1 [20.1 kB] 343s Get:348 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-pathfinder-geometry-dev s390x 0.5.1-1 [13.2 kB] 343s Get:349 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-winapi-util-dev s390x 0.1.6-1 [14.0 kB] 343s Get:350 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-same-file-dev s390x 1.0.6-1 [11.5 kB] 343s Get:351 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-walkdir-dev s390x 2.5.0-1 [24.5 kB] 343s Get:352 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-const-cstr-dev s390x 0.3.0-1 [9070 B] 343s Get:353 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-libloading-dev s390x 0.8.5-1 [29.2 kB] 343s Get:354 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-dlib-dev s390x 0.5.2-2 [7974 B] 343s Get:355 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-yeslogic-fontconfig-sys-dev s390x 3.0.1-1 [8110 B] 343s Get:356 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-font-kit-dev s390x 0.11.0-2 [56.2 kB] 343s Get:357 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-color-quant-dev s390x 1.1.0-1 [8464 B] 343s Get:358 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-weezl-dev s390x 0.1.5-1 [30.3 kB] 343s Get:359 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-gif-dev s390x 0.11.3-1 [31.9 kB] 343s Get:360 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-jpeg-decoder-dev s390x 0.3.0-1 [717 kB] 343s Get:361 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-num-integer-dev s390x 0.1.46-1 [22.6 kB] 343s Get:362 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-humantime-dev s390x 2.1.0-1 [18.2 kB] 343s Get:363 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-termcolor-dev s390x 1.4.1-1 [19.7 kB] 343s Get:364 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-env-logger-dev s390x 0.10.2-2 [34.4 kB] 343s Get:365 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-quickcheck-dev s390x 1.0.3-3 [27.9 kB] 343s Get:366 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-num-bigint-dev s390x 0.4.6-1 [84.9 kB] 343s Get:367 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-num-rational-dev s390x 0.4.2-1 [28.7 kB] 343s Get:368 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-png-dev s390x 0.17.7-3 [63.4 kB] 343s Get:369 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-qoi-dev s390x 0.4.1-2 [56.7 kB] 343s Get:370 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tiff-dev s390x 0.9.0-1 [1413 kB] 343s Get:371 http://ftpmaster.internal/ubuntu plucky/main s390x libsharpyuv0 s390x 1.4.0-0.1 [16.2 kB] 343s Get:372 http://ftpmaster.internal/ubuntu plucky/main s390x libwebp7 s390x 1.4.0-0.1 [204 kB] 343s Get:373 http://ftpmaster.internal/ubuntu plucky/main s390x libwebpdemux2 s390x 1.4.0-0.1 [12.2 kB] 343s Get:374 http://ftpmaster.internal/ubuntu plucky/main s390x libwebpmux3 s390x 1.4.0-0.1 [25.3 kB] 343s Get:375 http://ftpmaster.internal/ubuntu plucky/main s390x libwebpdecoder3 s390x 1.4.0-0.1 [89.8 kB] 343s Get:376 http://ftpmaster.internal/ubuntu plucky/main s390x libsharpyuv-dev s390x 1.4.0-0.1 [16.9 kB] 343s Get:377 http://ftpmaster.internal/ubuntu plucky/main s390x libwebp-dev s390x 1.4.0-0.1 [335 kB] 344s Get:378 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-libwebp-sys-dev s390x 0.9.5-1build1 [1357 kB] 344s Get:379 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-webp-dev s390x 0.2.6-1 [1846 kB] 344s Get:380 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-image-dev s390x 0.24.7-2 [229 kB] 344s Get:381 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-plotters-backend-dev s390x 0.3.7-1 [15.7 kB] 344s Get:382 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-plotters-bitmap-dev s390x 0.3.3-3 [17.1 kB] 344s Get:383 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-plotters-svg-dev s390x 0.3.5-1 [9260 B] 344s Get:384 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-web-sys-dev s390x 0.3.64-2 [581 kB] 344s Get:385 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-plotters-dev s390x 0.3.5-4 [118 kB] 344s Get:386 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-smol-dev all 2.0.2-1 [205 kB] 344s Get:387 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tinytemplate-dev s390x 1.2.1-1 [26.8 kB] 344s Get:388 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-criterion-dev all 0.5.1-6 [104 kB] 344s Get:389 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-phf-generator-dev s390x 0.11.2-2 [12.3 kB] 344s Get:390 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-phf-codegen-dev s390x 0.11.2-1 [14.3 kB] 344s Get:391 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-chrono-tz-build-dev s390x 0.2.1-1 [12.1 kB] 344s Get:392 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-chrono-tz-dev s390x 0.8.6-2 [513 kB] 344s Get:393 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ctor-dev s390x 0.1.26-1 [12.0 kB] 344s Get:394 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-powerfmt-macros-dev s390x 0.1.0-1 [10.5 kB] 344s Get:395 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-powerfmt-dev s390x 0.2.0-1 [16.5 kB] 344s Get:396 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-deranged-dev s390x 0.3.11-1 [18.4 kB] 344s Get:397 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-eui48-dev s390x 1.1.0-2 [16.1 kB] 344s Get:398 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-indenter-dev s390x 0.3.3-1 [8642 B] 344s Get:399 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-eyre-dev s390x 0.6.12-1 [38.0 kB] 344s Get:400 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-eyre+default-dev s390x 0.6.12-1 [1050 B] 344s Get:401 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-fancy-regex-dev s390x 0.11.0-2 [54.7 kB] 344s Get:402 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-fnv-dev s390x 1.0.7-1 [12.8 kB] 344s Get:403 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-geo-types-dev s390x 0.7.11-2 [32.8 kB] 344s Get:404 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-ghost-dev s390x 0.1.5-1 [16.1 kB] 344s Get:405 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-hmac-dev s390x 0.12.1-1 [43.9 kB] 344s Get:406 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-indoc-dev s390x 2.0.5-1 [16.7 kB] 344s Get:407 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-inventory-dev s390x 0.3.2-1 [13.5 kB] 344s Get:408 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-memoffset-dev s390x 0.8.0-1 [10.9 kB] 344s Get:409 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-num-conv-dev s390x 0.1.0-1 [8990 B] 344s Get:410 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-num-threads-dev s390x 0.1.7-1 [9154 B] 344s Get:411 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-postgres-derive-dev s390x 0.4.5-1 [13.4 kB] 344s Get:412 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-sha2-asm-dev s390x 0.6.2-2 [14.4 kB] 344s Get:413 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-sha2-dev s390x 0.10.8-1 [25.6 kB] 344s Get:414 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-unicode-bidi-dev s390x 0.3.13-1 [39.8 kB] 344s Get:415 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-unicode-normalization-dev s390x 0.1.22-1 [104 kB] 344s Get:416 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-stringprep-dev s390x 0.1.2-1 [16.5 kB] 344s Get:417 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-postgres-protocol-dev s390x 0.6.6-2 [25.9 kB] 344s Get:418 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-time-core-dev s390x 0.1.2-1 [9136 B] 344s Get:419 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-time-macros-dev s390x 0.2.16-1 [25.1 kB] 344s Get:420 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-time-dev s390x 0.3.36-2 [99.4 kB] 344s Get:421 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-postgres-types-dev s390x 0.2.6-2 [30.1 kB] 344s Get:422 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rand-xorshift-dev s390x 0.3.0-2 [10.9 kB] 344s Get:423 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-quick-error-dev s390x 2.0.1-1 [15.6 kB] 344s Get:424 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-tempfile-dev s390x 3.13.0-1 [35.0 kB] 344s Get:425 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rusty-fork-dev s390x 0.3.0-1 [20.4 kB] 344s Get:426 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-wait-timeout-dev s390x 0.2.0-1 [14.1 kB] 344s Get:427 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rusty-fork+wait-timeout-dev s390x 0.3.0-1 [1136 B] 344s Get:428 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-unarray-dev s390x 0.1.4-1 [14.6 kB] 344s Get:429 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-proptest-dev s390x 1.5.0-2 [171 kB] 345s Get:430 http://ftpmaster.internal/ubuntu plucky/universe s390x llvm-19-runtime s390x 1:19.1.2-1ubuntu1 [623 kB] 345s Get:431 http://ftpmaster.internal/ubuntu plucky/universe s390x llvm-runtime s390x 1:19.0-60~exp1 [5608 B] 345s Get:432 http://ftpmaster.internal/ubuntu plucky/universe s390x llvm-19-linker-tools s390x 1:19.1.2-1ubuntu1 [1529 kB] 345s Get:433 http://ftpmaster.internal/ubuntu plucky/universe s390x libpfm4 s390x 4.13.0+git83-g91970fe-1 [37.3 kB] 345s Get:434 http://ftpmaster.internal/ubuntu plucky/universe s390x llvm-19 s390x 1:19.1.2-1ubuntu1 [21.1 MB] 345s Get:435 http://ftpmaster.internal/ubuntu plucky/universe s390x llvm s390x 1:19.0-60~exp1 [4144 B] 345s Get:436 http://ftpmaster.internal/ubuntu plucky/universe s390x binutils-mingw-w64-x86-64 s390x 2.43.1-4ubuntu1+12 [3502 kB] 346s Get:437 http://ftpmaster.internal/ubuntu plucky/universe s390x binutils-mingw-w64-i686 s390x 2.43.1-4ubuntu1+12 [3215 kB] 346s Get:438 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-python3-dll-a-dev s390x 0.2.10-1 [31.6 kB] 346s Get:439 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-target-lexicon-dev s390x 0.12.14-1 [25.1 kB] 346s Get:440 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-pyo3-build-config-dev s390x 0.22.6-1 [30.8 kB] 346s Get:441 http://ftpmaster.internal/ubuntu plucky/main s390x python3.12-dev s390x 3.12.7-3 [505 kB] 346s Get:442 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-pyo3-ffi-dev s390x 0.22.6-1build1 [62.6 kB] 346s Get:443 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-pyo3-macros-backend-dev s390x 0.22.6-1 [58.5 kB] 346s Get:444 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-pyo3-macros-dev s390x 0.22.6-1 [10.4 kB] 346s Get:445 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rust-decimal-dev s390x 1.36.0-1 [114 kB] 346s Get:446 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-unindent-dev s390x 0.2.3-1 [9186 B] 346s Get:447 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-pyo3-dev s390x 0.22.6-1 [415 kB] 346s Get:448 http://ftpmaster.internal/ubuntu plucky/universe s390x librust-rustc-hash-dev s390x 1.1.0-1 [10.8 kB] 346s Get:449 http://ftpmaster.internal/ubuntu plucky/universe s390x pybuild-plugin-autopkgtest all 6.20241024 [1746 B] 346s Get:450 http://ftpmaster.internal/ubuntu plucky/main s390x python3-packaging all 24.2-1 [51.5 kB] 346s Get:451 http://ftpmaster.internal/ubuntu plucky/universe s390x python3-pyproject-hooks all 1.2.0-1 [10.2 kB] 346s Get:452 http://ftpmaster.internal/ubuntu plucky/universe s390x python3-toml all 0.10.2-1 [16.5 kB] 346s Get:453 http://ftpmaster.internal/ubuntu plucky/universe s390x python3-wheel all 0.45.1-1 [57.7 kB] 346s Get:454 http://ftpmaster.internal/ubuntu plucky/universe s390x python3-build all 1.2.2-1 [31.0 kB] 346s Get:455 http://ftpmaster.internal/ubuntu plucky/universe s390x python3-installer all 0.7.0+dfsg1-3 [17.4 kB] 346s Get:456 http://ftpmaster.internal/ubuntu plucky/universe s390x pybuild-plugin-pyproject all 6.20241024 [1728 B] 346s Get:457 http://ftpmaster.internal/ubuntu plucky/main s390x python3.13 s390x 3.13.0-2 [719 kB] 346s Get:458 http://ftpmaster.internal/ubuntu plucky-proposed/main s390x python3-all s390x 3.12.7-1 [890 B] 346s Get:459 http://ftpmaster.internal/ubuntu plucky/main s390x python3-dateutil all 2.9.0-3 [80.2 kB] 346s Get:460 http://ftpmaster.internal/ubuntu plucky/main s390x python3-sortedcontainers all 2.4.0-2 [27.6 kB] 346s Get:461 http://ftpmaster.internal/ubuntu plucky/universe s390x python3-hypothesis all 6.119.3-1 [329 kB] 346s Get:462 http://ftpmaster.internal/ubuntu plucky/universe s390x python3-iniconfig all 1.1.1-2 [6024 B] 346s Get:463 http://ftpmaster.internal/ubuntu plucky/universe s390x python3-pluggy all 1.5.0-1 [21.0 kB] 346s Get:464 http://ftpmaster.internal/ubuntu plucky/universe s390x python3-pytest all 8.3.3-1 [251 kB] 346s Get:465 http://ftpmaster.internal/ubuntu plucky/universe s390x python3-regex s390x 0.1.20240724-1build1 [310 kB] 346s Get:466 http://ftpmaster.internal/ubuntu plucky/main s390x python3-semantic-version all 2.10.0-2 [15.1 kB] 346s Get:467 http://ftpmaster.internal/ubuntu plucky/main s390x rustc s390x 1.80.1ubuntu2 [2754 B] 346s Get:468 http://ftpmaster.internal/ubuntu plucky/main s390x cargo s390x 1.80.1ubuntu2 [2246 B] 346s Get:469 http://ftpmaster.internal/ubuntu plucky/universe s390x python3-setuptools-rust all 1.9.0+dfsg-2 [23.1 kB] 346s Get:470 http://ftpmaster.internal/ubuntu plucky-proposed/universe s390x python3-tiktoken s390x 0.8.0-1build1 [787 kB] 347s Fetched 230 MB in 14s (16.8 MB/s) 347s Selecting previously unselected package libpython3.13-minimal:s390x. 347s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 55869 files and directories currently installed.) 347s Preparing to unpack .../000-libpython3.13-minimal_3.13.0-2_s390x.deb ... 347s Unpacking libpython3.13-minimal:s390x (3.13.0-2) ... 347s Selecting previously unselected package python3.13-minimal. 347s Preparing to unpack .../001-python3.13-minimal_3.13.0-2_s390x.deb ... 347s Unpacking python3.13-minimal (3.13.0-2) ... 347s Selecting previously unselected package m4. 347s Preparing to unpack .../002-m4_1.4.19-4build1_s390x.deb ... 347s Unpacking m4 (1.4.19-4build1) ... 347s Selecting previously unselected package autoconf. 347s Preparing to unpack .../003-autoconf_2.72-3_all.deb ... 347s Unpacking autoconf (2.72-3) ... 347s Selecting previously unselected package autotools-dev. 347s Preparing to unpack .../004-autotools-dev_20220109.1_all.deb ... 347s Unpacking autotools-dev (20220109.1) ... 347s Selecting previously unselected package automake. 347s Preparing to unpack .../005-automake_1%3a1.16.5-1.3ubuntu1_all.deb ... 347s Unpacking automake (1:1.16.5-1.3ubuntu1) ... 347s Selecting previously unselected package autopoint. 347s Preparing to unpack .../006-autopoint_0.22.5-2_all.deb ... 347s Unpacking autopoint (0.22.5-2) ... 347s Selecting previously unselected package libisl23:s390x. 347s Preparing to unpack .../007-libisl23_0.27-1_s390x.deb ... 347s Unpacking libisl23:s390x (0.27-1) ... 347s Selecting previously unselected package libmpc3:s390x. 347s Preparing to unpack .../008-libmpc3_1.3.1-1build2_s390x.deb ... 347s Unpacking libmpc3:s390x (1.3.1-1build2) ... 347s Selecting previously unselected package cpp-14-s390x-linux-gnu. 347s Preparing to unpack .../009-cpp-14-s390x-linux-gnu_14.2.0-8ubuntu1_s390x.deb ... 347s Unpacking cpp-14-s390x-linux-gnu (14.2.0-8ubuntu1) ... 347s Selecting previously unselected package cpp-14. 347s Preparing to unpack .../010-cpp-14_14.2.0-8ubuntu1_s390x.deb ... 347s Unpacking cpp-14 (14.2.0-8ubuntu1) ... 347s Selecting previously unselected package cpp-s390x-linux-gnu. 347s Preparing to unpack .../011-cpp-s390x-linux-gnu_4%3a14.1.0-2ubuntu1_s390x.deb ... 347s Unpacking cpp-s390x-linux-gnu (4:14.1.0-2ubuntu1) ... 347s Selecting previously unselected package cpp. 347s Preparing to unpack .../012-cpp_4%3a14.1.0-2ubuntu1_s390x.deb ... 347s Unpacking cpp (4:14.1.0-2ubuntu1) ... 347s Selecting previously unselected package libcc1-0:s390x. 347s Preparing to unpack .../013-libcc1-0_14.2.0-8ubuntu1_s390x.deb ... 347s Unpacking libcc1-0:s390x (14.2.0-8ubuntu1) ... 347s Selecting previously unselected package libgomp1:s390x. 347s Preparing to unpack .../014-libgomp1_14.2.0-8ubuntu1_s390x.deb ... 347s Unpacking libgomp1:s390x (14.2.0-8ubuntu1) ... 347s Selecting previously unselected package libitm1:s390x. 347s Preparing to unpack .../015-libitm1_14.2.0-8ubuntu1_s390x.deb ... 347s Unpacking libitm1:s390x (14.2.0-8ubuntu1) ... 347s Selecting previously unselected package libasan8:s390x. 347s Preparing to unpack .../016-libasan8_14.2.0-8ubuntu1_s390x.deb ... 347s Unpacking libasan8:s390x (14.2.0-8ubuntu1) ... 347s Selecting previously unselected package libubsan1:s390x. 347s Preparing to unpack .../017-libubsan1_14.2.0-8ubuntu1_s390x.deb ... 347s Unpacking libubsan1:s390x (14.2.0-8ubuntu1) ... 347s Selecting previously unselected package libgcc-14-dev:s390x. 347s Preparing to unpack .../018-libgcc-14-dev_14.2.0-8ubuntu1_s390x.deb ... 347s Unpacking libgcc-14-dev:s390x (14.2.0-8ubuntu1) ... 348s Selecting previously unselected package gcc-14-s390x-linux-gnu. 348s Preparing to unpack .../019-gcc-14-s390x-linux-gnu_14.2.0-8ubuntu1_s390x.deb ... 348s Unpacking gcc-14-s390x-linux-gnu (14.2.0-8ubuntu1) ... 348s Selecting previously unselected package gcc-14. 348s Preparing to unpack .../020-gcc-14_14.2.0-8ubuntu1_s390x.deb ... 348s Unpacking gcc-14 (14.2.0-8ubuntu1) ... 348s Selecting previously unselected package gcc-s390x-linux-gnu. 348s Preparing to unpack .../021-gcc-s390x-linux-gnu_4%3a14.1.0-2ubuntu1_s390x.deb ... 348s Unpacking gcc-s390x-linux-gnu (4:14.1.0-2ubuntu1) ... 348s Selecting previously unselected package gcc. 348s Preparing to unpack .../022-gcc_4%3a14.1.0-2ubuntu1_s390x.deb ... 348s Unpacking gcc (4:14.1.0-2ubuntu1) ... 348s Selecting previously unselected package libstdc++-14-dev:s390x. 348s Preparing to unpack .../023-libstdc++-14-dev_14.2.0-8ubuntu1_s390x.deb ... 348s Unpacking libstdc++-14-dev:s390x (14.2.0-8ubuntu1) ... 348s Selecting previously unselected package g++-14-s390x-linux-gnu. 348s Preparing to unpack .../024-g++-14-s390x-linux-gnu_14.2.0-8ubuntu1_s390x.deb ... 348s Unpacking g++-14-s390x-linux-gnu (14.2.0-8ubuntu1) ... 348s Selecting previously unselected package g++-14. 348s Preparing to unpack .../025-g++-14_14.2.0-8ubuntu1_s390x.deb ... 348s Unpacking g++-14 (14.2.0-8ubuntu1) ... 348s Selecting previously unselected package g++-s390x-linux-gnu. 348s Preparing to unpack .../026-g++-s390x-linux-gnu_4%3a14.1.0-2ubuntu1_s390x.deb ... 348s Unpacking g++-s390x-linux-gnu (4:14.1.0-2ubuntu1) ... 348s Selecting previously unselected package g++. 348s Preparing to unpack .../027-g++_4%3a14.1.0-2ubuntu1_s390x.deb ... 348s Unpacking g++ (4:14.1.0-2ubuntu1) ... 348s Selecting previously unselected package build-essential. 348s Preparing to unpack .../028-build-essential_12.10ubuntu1_s390x.deb ... 348s Unpacking build-essential (12.10ubuntu1) ... 348s Selecting previously unselected package libhttp-parser2.9:s390x. 348s Preparing to unpack .../029-libhttp-parser2.9_2.9.4-6build1_s390x.deb ... 348s Unpacking libhttp-parser2.9:s390x (2.9.4-6build1) ... 348s Selecting previously unselected package libgit2-1.7:s390x. 348s Preparing to unpack .../030-libgit2-1.7_1.7.2+ds-1ubuntu3_s390x.deb ... 348s Unpacking libgit2-1.7:s390x (1.7.2+ds-1ubuntu3) ... 348s Selecting previously unselected package libstd-rust-1.80:s390x. 348s Preparing to unpack .../031-libstd-rust-1.80_1.80.1+dfsg0ubuntu1-0ubuntu1_s390x.deb ... 348s Unpacking libstd-rust-1.80:s390x (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 349s Selecting previously unselected package libstd-rust-1.80-dev:s390x. 349s Preparing to unpack .../032-libstd-rust-1.80-dev_1.80.1+dfsg0ubuntu1-0ubuntu1_s390x.deb ... 349s Unpacking libstd-rust-1.80-dev:s390x (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 349s Selecting previously unselected package rustc-1.80. 349s Preparing to unpack .../033-rustc-1.80_1.80.1+dfsg0ubuntu1-0ubuntu1_s390x.deb ... 349s Unpacking rustc-1.80 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 349s Selecting previously unselected package cargo-1.80. 349s Preparing to unpack .../034-cargo-1.80_1.80.1+dfsg0ubuntu1-0ubuntu1_s390x.deb ... 349s Unpacking cargo-1.80 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 349s Selecting previously unselected package libjsoncpp25:s390x. 349s Preparing to unpack .../035-libjsoncpp25_1.9.5-6build1_s390x.deb ... 349s Unpacking libjsoncpp25:s390x (1.9.5-6build1) ... 349s Selecting previously unselected package librhash0:s390x. 349s Preparing to unpack .../036-librhash0_1.4.3-3build1_s390x.deb ... 349s Unpacking librhash0:s390x (1.4.3-3build1) ... 349s Selecting previously unselected package cmake-data. 349s Preparing to unpack .../037-cmake-data_3.30.3-1_all.deb ... 349s Unpacking cmake-data (3.30.3-1) ... 350s Selecting previously unselected package cmake. 350s Preparing to unpack .../038-cmake_3.30.3-1_s390x.deb ... 350s Unpacking cmake (3.30.3-1) ... 350s Selecting previously unselected package libdebhelper-perl. 350s Preparing to unpack .../039-libdebhelper-perl_13.20ubuntu1_all.deb ... 350s Unpacking libdebhelper-perl (13.20ubuntu1) ... 350s Selecting previously unselected package libtool. 350s Preparing to unpack .../040-libtool_2.4.7-8_all.deb ... 350s Unpacking libtool (2.4.7-8) ... 350s Selecting previously unselected package dh-autoreconf. 350s Preparing to unpack .../041-dh-autoreconf_20_all.deb ... 350s Unpacking dh-autoreconf (20) ... 350s Selecting previously unselected package libarchive-zip-perl. 350s Preparing to unpack .../042-libarchive-zip-perl_1.68-1_all.deb ... 350s Unpacking libarchive-zip-perl (1.68-1) ... 350s Selecting previously unselected package libfile-stripnondeterminism-perl. 350s Preparing to unpack .../043-libfile-stripnondeterminism-perl_1.14.0-1_all.deb ... 350s Unpacking libfile-stripnondeterminism-perl (1.14.0-1) ... 350s Selecting previously unselected package dh-strip-nondeterminism. 350s Preparing to unpack .../044-dh-strip-nondeterminism_1.14.0-1_all.deb ... 350s Unpacking dh-strip-nondeterminism (1.14.0-1) ... 350s Selecting previously unselected package debugedit. 350s Preparing to unpack .../045-debugedit_1%3a5.1-1_s390x.deb ... 350s Unpacking debugedit (1:5.1-1) ... 350s Selecting previously unselected package dwz. 350s Preparing to unpack .../046-dwz_0.15-1build6_s390x.deb ... 350s Unpacking dwz (0.15-1build6) ... 350s Selecting previously unselected package gettext. 350s Preparing to unpack .../047-gettext_0.22.5-2_s390x.deb ... 350s Unpacking gettext (0.22.5-2) ... 350s Selecting previously unselected package intltool-debian. 350s Preparing to unpack .../048-intltool-debian_0.35.0+20060710.6_all.deb ... 350s Unpacking intltool-debian (0.35.0+20060710.6) ... 350s Selecting previously unselected package po-debconf. 350s Preparing to unpack .../049-po-debconf_1.0.21+nmu1_all.deb ... 350s Unpacking po-debconf (1.0.21+nmu1) ... 350s Selecting previously unselected package debhelper. 350s Preparing to unpack .../050-debhelper_13.20ubuntu1_all.deb ... 350s Unpacking debhelper (13.20ubuntu1) ... 350s Selecting previously unselected package dh-python. 350s Preparing to unpack .../051-dh-python_6.20241024_all.deb ... 350s Unpacking dh-python (6.20241024) ... 350s Selecting previously unselected package fonts-dejavu-mono. 350s Preparing to unpack .../052-fonts-dejavu-mono_2.37-8_all.deb ... 350s Unpacking fonts-dejavu-mono (2.37-8) ... 350s Selecting previously unselected package fonts-dejavu-core. 350s Preparing to unpack .../053-fonts-dejavu-core_2.37-8_all.deb ... 350s Unpacking fonts-dejavu-core (2.37-8) ... 350s Selecting previously unselected package fontconfig-config. 350s Preparing to unpack .../054-fontconfig-config_2.15.0-1.1ubuntu2_s390x.deb ... 350s Unpacking fontconfig-config (2.15.0-1.1ubuntu2) ... 350s Selecting previously unselected package libbrotli-dev:s390x. 350s Preparing to unpack .../055-libbrotli-dev_1.1.0-2build3_s390x.deb ... 350s Unpacking libbrotli-dev:s390x (1.1.0-2build3) ... 350s Selecting previously unselected package libbz2-dev:s390x. 350s Preparing to unpack .../056-libbz2-dev_1.0.8-6_s390x.deb ... 350s Unpacking libbz2-dev:s390x (1.0.8-6) ... 350s Selecting previously unselected package libexpat1-dev:s390x. 350s Preparing to unpack .../057-libexpat1-dev_2.6.4-1_s390x.deb ... 350s Unpacking libexpat1-dev:s390x (2.6.4-1) ... 350s Selecting previously unselected package libfreetype6:s390x. 350s Preparing to unpack .../058-libfreetype6_2.13.3+dfsg-1_s390x.deb ... 350s Unpacking libfreetype6:s390x (2.13.3+dfsg-1) ... 350s Selecting previously unselected package libfontconfig1:s390x. 350s Preparing to unpack .../059-libfontconfig1_2.15.0-1.1ubuntu2_s390x.deb ... 350s Unpacking libfontconfig1:s390x (2.15.0-1.1ubuntu2) ... 350s Selecting previously unselected package zlib1g-dev:s390x. 350s Preparing to unpack .../060-zlib1g-dev_1%3a1.3.dfsg+really1.3.1-1ubuntu1_s390x.deb ... 350s Unpacking zlib1g-dev:s390x (1:1.3.dfsg+really1.3.1-1ubuntu1) ... 350s Selecting previously unselected package libpng-dev:s390x. 350s Preparing to unpack .../061-libpng-dev_1.6.44-2_s390x.deb ... 350s Unpacking libpng-dev:s390x (1.6.44-2) ... 350s Selecting previously unselected package libfreetype-dev:s390x. 350s Preparing to unpack .../062-libfreetype-dev_2.13.3+dfsg-1_s390x.deb ... 350s Unpacking libfreetype-dev:s390x (2.13.3+dfsg-1) ... 350s Selecting previously unselected package uuid-dev:s390x. 350s Preparing to unpack .../063-uuid-dev_2.40.2-1ubuntu1_s390x.deb ... 350s Unpacking uuid-dev:s390x (2.40.2-1ubuntu1) ... 350s Selecting previously unselected package libpkgconf3:s390x. 350s Preparing to unpack .../064-libpkgconf3_1.8.1-4_s390x.deb ... 350s Unpacking libpkgconf3:s390x (1.8.1-4) ... 350s Selecting previously unselected package pkgconf-bin. 350s Preparing to unpack .../065-pkgconf-bin_1.8.1-4_s390x.deb ... 350s Unpacking pkgconf-bin (1.8.1-4) ... 350s Selecting previously unselected package pkgconf:s390x. 350s Preparing to unpack .../066-pkgconf_1.8.1-4_s390x.deb ... 350s Unpacking pkgconf:s390x (1.8.1-4) ... 350s Selecting previously unselected package libfontconfig-dev:s390x. 350s Preparing to unpack .../067-libfontconfig-dev_2.15.0-1.1ubuntu2_s390x.deb ... 350s Unpacking libfontconfig-dev:s390x (2.15.0-1.1ubuntu2) ... 350s Selecting previously unselected package libpython3.12-dev:s390x. 350s Preparing to unpack .../068-libpython3.12-dev_3.12.7-3_s390x.deb ... 350s Unpacking libpython3.12-dev:s390x (3.12.7-3) ... 351s Selecting previously unselected package libpython3-dev:s390x. 351s Preparing to unpack .../069-libpython3-dev_3.12.7-1_s390x.deb ... 351s Unpacking libpython3-dev:s390x (3.12.7-1) ... 351s Selecting previously unselected package libpython3.13-stdlib:s390x. 351s Preparing to unpack .../070-libpython3.13-stdlib_3.13.0-2_s390x.deb ... 351s Unpacking libpython3.13-stdlib:s390x (3.13.0-2) ... 351s Selecting previously unselected package libpython3.13:s390x. 351s Preparing to unpack .../071-libpython3.13_3.13.0-2_s390x.deb ... 351s Unpacking libpython3.13:s390x (3.13.0-2) ... 351s Selecting previously unselected package libpython3.13-dev:s390x. 351s Preparing to unpack .../072-libpython3.13-dev_3.13.0-2_s390x.deb ... 351s Unpacking libpython3.13-dev:s390x (3.13.0-2) ... 351s Selecting previously unselected package libpython3-all-dev:s390x. 351s Preparing to unpack .../073-libpython3-all-dev_3.12.7-1_s390x.deb ... 351s Unpacking libpython3-all-dev:s390x (3.12.7-1) ... 351s Selecting previously unselected package librust-ab-glyph-rasterizer-dev:s390x. 351s Preparing to unpack .../074-librust-ab-glyph-rasterizer-dev_0.1.7-1_s390x.deb ... 351s Unpacking librust-ab-glyph-rasterizer-dev:s390x (0.1.7-1) ... 351s Selecting previously unselected package librust-libm-dev:s390x. 351s Preparing to unpack .../075-librust-libm-dev_0.2.8-1_s390x.deb ... 351s Unpacking librust-libm-dev:s390x (0.2.8-1) ... 351s Selecting previously unselected package librust-ab-glyph-rasterizer+libm-dev:s390x. 351s Preparing to unpack .../076-librust-ab-glyph-rasterizer+libm-dev_0.1.7-1_s390x.deb ... 351s Unpacking librust-ab-glyph-rasterizer+libm-dev:s390x (0.1.7-1) ... 351s Selecting previously unselected package librust-core-maths-dev:s390x. 351s Preparing to unpack .../077-librust-core-maths-dev_0.1.0-2_s390x.deb ... 351s Unpacking librust-core-maths-dev:s390x (0.1.0-2) ... 351s Selecting previously unselected package librust-ttf-parser-dev:s390x. 351s Preparing to unpack .../078-librust-ttf-parser-dev_0.24.1-1_s390x.deb ... 351s Unpacking librust-ttf-parser-dev:s390x (0.24.1-1) ... 351s Selecting previously unselected package librust-owned-ttf-parser-dev:s390x. 351s Preparing to unpack .../079-librust-owned-ttf-parser-dev_0.24.0-1_s390x.deb ... 351s Unpacking librust-owned-ttf-parser-dev:s390x (0.24.0-1) ... 351s Selecting previously unselected package librust-ab-glyph-dev:s390x. 351s Preparing to unpack .../080-librust-ab-glyph-dev_0.2.28-1_s390x.deb ... 351s Unpacking librust-ab-glyph-dev:s390x (0.2.28-1) ... 351s Selecting previously unselected package librust-cfg-if-dev:s390x. 351s Preparing to unpack .../081-librust-cfg-if-dev_1.0.0-1_s390x.deb ... 351s Unpacking librust-cfg-if-dev:s390x (1.0.0-1) ... 351s Selecting previously unselected package librust-cpp-demangle-dev:s390x. 351s Preparing to unpack .../082-librust-cpp-demangle-dev_0.4.0-1_s390x.deb ... 351s Unpacking librust-cpp-demangle-dev:s390x (0.4.0-1) ... 351s Selecting previously unselected package librust-fallible-iterator-dev:s390x. 351s Preparing to unpack .../083-librust-fallible-iterator-dev_0.3.0-2_s390x.deb ... 351s Unpacking librust-fallible-iterator-dev:s390x (0.3.0-2) ... 351s Selecting previously unselected package librust-unicode-ident-dev:s390x. 351s Preparing to unpack .../084-librust-unicode-ident-dev_1.0.13-1_s390x.deb ... 351s Unpacking librust-unicode-ident-dev:s390x (1.0.13-1) ... 351s Selecting previously unselected package librust-proc-macro2-dev:s390x. 351s Preparing to unpack .../085-librust-proc-macro2-dev_1.0.86-1_s390x.deb ... 351s Unpacking librust-proc-macro2-dev:s390x (1.0.86-1) ... 351s Selecting previously unselected package librust-quote-dev:s390x. 351s Preparing to unpack .../086-librust-quote-dev_1.0.37-1_s390x.deb ... 351s Unpacking librust-quote-dev:s390x (1.0.37-1) ... 351s Selecting previously unselected package librust-syn-dev:s390x. 351s Preparing to unpack .../087-librust-syn-dev_2.0.85-1_s390x.deb ... 351s Unpacking librust-syn-dev:s390x (2.0.85-1) ... 351s Selecting previously unselected package librust-derive-arbitrary-dev:s390x. 351s Preparing to unpack .../088-librust-derive-arbitrary-dev_1.3.2-1_s390x.deb ... 351s Unpacking librust-derive-arbitrary-dev:s390x (1.3.2-1) ... 351s Selecting previously unselected package librust-arbitrary-dev:s390x. 351s Preparing to unpack .../089-librust-arbitrary-dev_1.3.2-1_s390x.deb ... 351s Unpacking librust-arbitrary-dev:s390x (1.3.2-1) ... 351s Selecting previously unselected package librust-equivalent-dev:s390x. 351s Preparing to unpack .../090-librust-equivalent-dev_1.0.1-1_s390x.deb ... 351s Unpacking librust-equivalent-dev:s390x (1.0.1-1) ... 351s Selecting previously unselected package librust-critical-section-dev:s390x. 351s Preparing to unpack .../091-librust-critical-section-dev_1.1.3-1_s390x.deb ... 351s Unpacking librust-critical-section-dev:s390x (1.1.3-1) ... 351s Selecting previously unselected package librust-serde-derive-dev:s390x. 351s Preparing to unpack .../092-librust-serde-derive-dev_1.0.210-1_s390x.deb ... 351s Unpacking librust-serde-derive-dev:s390x (1.0.210-1) ... 351s Selecting previously unselected package librust-serde-dev:s390x. 351s Preparing to unpack .../093-librust-serde-dev_1.0.210-2_s390x.deb ... 351s Unpacking librust-serde-dev:s390x (1.0.210-2) ... 351s Selecting previously unselected package librust-portable-atomic-dev:s390x. 351s Preparing to unpack .../094-librust-portable-atomic-dev_1.9.0-4_s390x.deb ... 351s Unpacking librust-portable-atomic-dev:s390x (1.9.0-4) ... 351s Selecting previously unselected package librust-rustc-std-workspace-core-dev:s390x. 351s Preparing to unpack .../095-librust-rustc-std-workspace-core-dev_1.0.0-1_s390x.deb ... 351s Unpacking librust-rustc-std-workspace-core-dev:s390x (1.0.0-1) ... 351s Selecting previously unselected package librust-libc-dev:s390x. 351s Preparing to unpack .../096-librust-libc-dev_0.2.161-1_s390x.deb ... 351s Unpacking librust-libc-dev:s390x (0.2.161-1) ... 351s Selecting previously unselected package librust-getrandom-dev:s390x. 351s Preparing to unpack .../097-librust-getrandom-dev_0.2.12-1_s390x.deb ... 351s Unpacking librust-getrandom-dev:s390x (0.2.12-1) ... 351s Selecting previously unselected package librust-smallvec-dev:s390x. 351s Preparing to unpack .../098-librust-smallvec-dev_1.13.2-1_s390x.deb ... 351s Unpacking librust-smallvec-dev:s390x (1.13.2-1) ... 351s Selecting previously unselected package librust-parking-lot-core-dev:s390x. 351s Preparing to unpack .../099-librust-parking-lot-core-dev_0.9.10-1_s390x.deb ... 351s Unpacking librust-parking-lot-core-dev:s390x (0.9.10-1) ... 351s Selecting previously unselected package librust-once-cell-dev:s390x. 351s Preparing to unpack .../100-librust-once-cell-dev_1.20.2-1_s390x.deb ... 351s Unpacking librust-once-cell-dev:s390x (1.20.2-1) ... 351s Selecting previously unselected package librust-crunchy-dev:s390x. 351s Preparing to unpack .../101-librust-crunchy-dev_0.2.2-1_s390x.deb ... 351s Unpacking librust-crunchy-dev:s390x (0.2.2-1) ... 351s Selecting previously unselected package librust-tiny-keccak-dev:s390x. 351s Preparing to unpack .../102-librust-tiny-keccak-dev_2.0.2-1_s390x.deb ... 351s Unpacking librust-tiny-keccak-dev:s390x (2.0.2-1) ... 351s Selecting previously unselected package librust-const-random-macro-dev:s390x. 351s Preparing to unpack .../103-librust-const-random-macro-dev_0.1.16-2_s390x.deb ... 351s Unpacking librust-const-random-macro-dev:s390x (0.1.16-2) ... 351s Selecting previously unselected package librust-const-random-dev:s390x. 351s Preparing to unpack .../104-librust-const-random-dev_0.1.17-2_s390x.deb ... 351s Unpacking librust-const-random-dev:s390x (0.1.17-2) ... 351s Selecting previously unselected package librust-version-check-dev:s390x. 351s Preparing to unpack .../105-librust-version-check-dev_0.9.5-1_s390x.deb ... 351s Unpacking librust-version-check-dev:s390x (0.9.5-1) ... 351s Selecting previously unselected package librust-byteorder-dev:s390x. 351s Preparing to unpack .../106-librust-byteorder-dev_1.5.0-1_s390x.deb ... 351s Unpacking librust-byteorder-dev:s390x (1.5.0-1) ... 351s Selecting previously unselected package librust-zerocopy-derive-dev:s390x. 351s Preparing to unpack .../107-librust-zerocopy-derive-dev_0.7.32-2_s390x.deb ... 351s Unpacking librust-zerocopy-derive-dev:s390x (0.7.32-2) ... 351s Selecting previously unselected package librust-zerocopy-dev:s390x. 351s Preparing to unpack .../108-librust-zerocopy-dev_0.7.32-1_s390x.deb ... 351s Unpacking librust-zerocopy-dev:s390x (0.7.32-1) ... 351s Selecting previously unselected package librust-ahash-dev. 351s Preparing to unpack .../109-librust-ahash-dev_0.8.11-8_all.deb ... 351s Unpacking librust-ahash-dev (0.8.11-8) ... 351s Selecting previously unselected package librust-allocator-api2-dev:s390x. 351s Preparing to unpack .../110-librust-allocator-api2-dev_0.2.16-1_s390x.deb ... 351s Unpacking librust-allocator-api2-dev:s390x (0.2.16-1) ... 351s Selecting previously unselected package librust-compiler-builtins-dev:s390x. 351s Preparing to unpack .../111-librust-compiler-builtins-dev_0.1.101-1_s390x.deb ... 351s Unpacking librust-compiler-builtins-dev:s390x (0.1.101-1) ... 351s Selecting previously unselected package librust-either-dev:s390x. 351s Preparing to unpack .../112-librust-either-dev_1.13.0-1_s390x.deb ... 351s Unpacking librust-either-dev:s390x (1.13.0-1) ... 351s Selecting previously unselected package librust-crossbeam-utils-dev:s390x. 351s Preparing to unpack .../113-librust-crossbeam-utils-dev_0.8.19-1_s390x.deb ... 351s Unpacking librust-crossbeam-utils-dev:s390x (0.8.19-1) ... 351s Selecting previously unselected package librust-crossbeam-epoch-dev:s390x. 351s Preparing to unpack .../114-librust-crossbeam-epoch-dev_0.9.18-1_s390x.deb ... 351s Unpacking librust-crossbeam-epoch-dev:s390x (0.9.18-1) ... 351s Selecting previously unselected package librust-crossbeam-epoch+std-dev:s390x. 351s Preparing to unpack .../115-librust-crossbeam-epoch+std-dev_0.9.18-1_s390x.deb ... 351s Unpacking librust-crossbeam-epoch+std-dev:s390x (0.9.18-1) ... 351s Selecting previously unselected package librust-crossbeam-deque-dev:s390x. 351s Preparing to unpack .../116-librust-crossbeam-deque-dev_0.8.5-1_s390x.deb ... 351s Unpacking librust-crossbeam-deque-dev:s390x (0.8.5-1) ... 351s Selecting previously unselected package librust-rayon-core-dev:s390x. 351s Preparing to unpack .../117-librust-rayon-core-dev_1.12.1-1_s390x.deb ... 351s Unpacking librust-rayon-core-dev:s390x (1.12.1-1) ... 351s Selecting previously unselected package librust-rayon-dev:s390x. 351s Preparing to unpack .../118-librust-rayon-dev_1.10.0-1_s390x.deb ... 351s Unpacking librust-rayon-dev:s390x (1.10.0-1) ... 351s Selecting previously unselected package librust-hashbrown-dev:s390x. 351s Preparing to unpack .../119-librust-hashbrown-dev_0.14.5-5_s390x.deb ... 351s Unpacking librust-hashbrown-dev:s390x (0.14.5-5) ... 351s Selecting previously unselected package librust-indexmap-dev:s390x. 351s Preparing to unpack .../120-librust-indexmap-dev_2.2.6-1_s390x.deb ... 351s Unpacking librust-indexmap-dev:s390x (2.2.6-1) ... 351s Selecting previously unselected package librust-stable-deref-trait-dev:s390x. 351s Preparing to unpack .../121-librust-stable-deref-trait-dev_1.2.0-1_s390x.deb ... 351s Unpacking librust-stable-deref-trait-dev:s390x (1.2.0-1) ... 351s Selecting previously unselected package librust-gimli-dev:s390x. 351s Preparing to unpack .../122-librust-gimli-dev_0.28.1-2_s390x.deb ... 351s Unpacking librust-gimli-dev:s390x (0.28.1-2) ... 351s Selecting previously unselected package librust-memmap2-dev:s390x. 351s Preparing to unpack .../123-librust-memmap2-dev_0.9.3-1_s390x.deb ... 351s Unpacking librust-memmap2-dev:s390x (0.9.3-1) ... 351s Selecting previously unselected package librust-crc32fast-dev:s390x. 351s Preparing to unpack .../124-librust-crc32fast-dev_1.4.2-1_s390x.deb ... 351s Unpacking librust-crc32fast-dev:s390x (1.4.2-1) ... 351s Selecting previously unselected package pkg-config:s390x. 351s Preparing to unpack .../125-pkg-config_1.8.1-4_s390x.deb ... 351s Unpacking pkg-config:s390x (1.8.1-4) ... 351s Selecting previously unselected package librust-pkg-config-dev:s390x. 351s Preparing to unpack .../126-librust-pkg-config-dev_0.3.27-1_s390x.deb ... 351s Unpacking librust-pkg-config-dev:s390x (0.3.27-1) ... 351s Selecting previously unselected package librust-libz-sys-dev:s390x. 351s Preparing to unpack .../127-librust-libz-sys-dev_1.1.20-1_s390x.deb ... 351s Unpacking librust-libz-sys-dev:s390x (1.1.20-1) ... 351s Selecting previously unselected package librust-adler-dev:s390x. 351s Preparing to unpack .../128-librust-adler-dev_1.0.2-2_s390x.deb ... 351s Unpacking librust-adler-dev:s390x (1.0.2-2) ... 351s Selecting previously unselected package librust-miniz-oxide-dev:s390x. 351s Preparing to unpack .../129-librust-miniz-oxide-dev_0.7.1-1_s390x.deb ... 351s Unpacking librust-miniz-oxide-dev:s390x (0.7.1-1) ... 351s Selecting previously unselected package librust-flate2-dev:s390x. 351s Preparing to unpack .../130-librust-flate2-dev_1.0.34-1_s390x.deb ... 351s Unpacking librust-flate2-dev:s390x (1.0.34-1) ... 351s Selecting previously unselected package librust-sval-derive-dev:s390x. 351s Preparing to unpack .../131-librust-sval-derive-dev_2.6.1-2_s390x.deb ... 351s Unpacking librust-sval-derive-dev:s390x (2.6.1-2) ... 351s Selecting previously unselected package librust-sval-dev:s390x. 351s Preparing to unpack .../132-librust-sval-dev_2.6.1-2_s390x.deb ... 351s Unpacking librust-sval-dev:s390x (2.6.1-2) ... 351s Selecting previously unselected package librust-sval-ref-dev:s390x. 351s Preparing to unpack .../133-librust-sval-ref-dev_2.6.1-1_s390x.deb ... 351s Unpacking librust-sval-ref-dev:s390x (2.6.1-1) ... 352s Selecting previously unselected package librust-erased-serde-dev:s390x. 352s Preparing to unpack .../134-librust-erased-serde-dev_0.3.31-1_s390x.deb ... 352s Unpacking librust-erased-serde-dev:s390x (0.3.31-1) ... 352s Selecting previously unselected package librust-serde-fmt-dev. 352s Preparing to unpack .../135-librust-serde-fmt-dev_1.0.3-3_all.deb ... 352s Unpacking librust-serde-fmt-dev (1.0.3-3) ... 352s Selecting previously unselected package librust-syn-1-dev:s390x. 352s Preparing to unpack .../136-librust-syn-1-dev_1.0.109-2_s390x.deb ... 352s Unpacking librust-syn-1-dev:s390x (1.0.109-2) ... 352s Selecting previously unselected package librust-no-panic-dev:s390x. 352s Preparing to unpack .../137-librust-no-panic-dev_0.1.13-1_s390x.deb ... 352s Unpacking librust-no-panic-dev:s390x (0.1.13-1) ... 352s Selecting previously unselected package librust-itoa-dev:s390x. 352s Preparing to unpack .../138-librust-itoa-dev_1.0.9-1_s390x.deb ... 352s Unpacking librust-itoa-dev:s390x (1.0.9-1) ... 352s Selecting previously unselected package librust-ryu-dev:s390x. 352s Preparing to unpack .../139-librust-ryu-dev_1.0.15-1_s390x.deb ... 352s Unpacking librust-ryu-dev:s390x (1.0.15-1) ... 352s Selecting previously unselected package librust-serde-json-dev:s390x. 352s Preparing to unpack .../140-librust-serde-json-dev_1.0.128-1_s390x.deb ... 352s Unpacking librust-serde-json-dev:s390x (1.0.128-1) ... 352s Selecting previously unselected package librust-serde-test-dev:s390x. 352s Preparing to unpack .../141-librust-serde-test-dev_1.0.171-1_s390x.deb ... 352s Unpacking librust-serde-test-dev:s390x (1.0.171-1) ... 352s Selecting previously unselected package librust-value-bag-serde1-dev:s390x. 352s Preparing to unpack .../142-librust-value-bag-serde1-dev_1.9.0-1_s390x.deb ... 352s Unpacking librust-value-bag-serde1-dev:s390x (1.9.0-1) ... 352s Selecting previously unselected package librust-sval-buffer-dev:s390x. 352s Preparing to unpack .../143-librust-sval-buffer-dev_2.6.1-1_s390x.deb ... 352s Unpacking librust-sval-buffer-dev:s390x (2.6.1-1) ... 352s Selecting previously unselected package librust-sval-dynamic-dev:s390x. 352s Preparing to unpack .../144-librust-sval-dynamic-dev_2.6.1-1_s390x.deb ... 352s Unpacking librust-sval-dynamic-dev:s390x (2.6.1-1) ... 352s Selecting previously unselected package librust-sval-fmt-dev:s390x. 352s Preparing to unpack .../145-librust-sval-fmt-dev_2.6.1-1_s390x.deb ... 352s Unpacking librust-sval-fmt-dev:s390x (2.6.1-1) ... 352s Selecting previously unselected package librust-sval-serde-dev:s390x. 352s Preparing to unpack .../146-librust-sval-serde-dev_2.6.1-1_s390x.deb ... 352s Unpacking librust-sval-serde-dev:s390x (2.6.1-1) ... 352s Selecting previously unselected package librust-value-bag-sval2-dev:s390x. 352s Preparing to unpack .../147-librust-value-bag-sval2-dev_1.9.0-1_s390x.deb ... 352s Unpacking librust-value-bag-sval2-dev:s390x (1.9.0-1) ... 352s Selecting previously unselected package librust-value-bag-dev:s390x. 352s Preparing to unpack .../148-librust-value-bag-dev_1.9.0-1_s390x.deb ... 352s Unpacking librust-value-bag-dev:s390x (1.9.0-1) ... 352s Selecting previously unselected package librust-log-dev:s390x. 352s Preparing to unpack .../149-librust-log-dev_0.4.22-1_s390x.deb ... 352s Unpacking librust-log-dev:s390x (0.4.22-1) ... 352s Selecting previously unselected package librust-memchr-dev:s390x. 352s Preparing to unpack .../150-librust-memchr-dev_2.7.4-1_s390x.deb ... 352s Unpacking librust-memchr-dev:s390x (2.7.4-1) ... 352s Selecting previously unselected package librust-ppv-lite86-dev:s390x. 352s Preparing to unpack .../151-librust-ppv-lite86-dev_0.2.16-1_s390x.deb ... 352s Unpacking librust-ppv-lite86-dev:s390x (0.2.16-1) ... 352s Selecting previously unselected package librust-rand-core-dev:s390x. 352s Preparing to unpack .../152-librust-rand-core-dev_0.6.4-2_s390x.deb ... 352s Unpacking librust-rand-core-dev:s390x (0.6.4-2) ... 352s Selecting previously unselected package librust-rand-chacha-dev:s390x. 352s Preparing to unpack .../153-librust-rand-chacha-dev_0.3.1-2_s390x.deb ... 352s Unpacking librust-rand-chacha-dev:s390x (0.3.1-2) ... 352s Selecting previously unselected package librust-rand-core+getrandom-dev:s390x. 352s Preparing to unpack .../154-librust-rand-core+getrandom-dev_0.6.4-2_s390x.deb ... 352s Unpacking librust-rand-core+getrandom-dev:s390x (0.6.4-2) ... 352s Selecting previously unselected package librust-rand-core+serde-dev:s390x. 352s Preparing to unpack .../155-librust-rand-core+serde-dev_0.6.4-2_s390x.deb ... 352s Unpacking librust-rand-core+serde-dev:s390x (0.6.4-2) ... 352s Selecting previously unselected package librust-rand-core+std-dev:s390x. 352s Preparing to unpack .../156-librust-rand-core+std-dev_0.6.4-2_s390x.deb ... 352s Unpacking librust-rand-core+std-dev:s390x (0.6.4-2) ... 352s Selecting previously unselected package librust-rand-dev:s390x. 352s Preparing to unpack .../157-librust-rand-dev_0.8.5-1_s390x.deb ... 352s Unpacking librust-rand-dev:s390x (0.8.5-1) ... 352s Selecting previously unselected package librust-unicode-segmentation-dev:s390x. 352s Preparing to unpack .../158-librust-unicode-segmentation-dev_1.11.0-1_s390x.deb ... 352s Unpacking librust-unicode-segmentation-dev:s390x (1.11.0-1) ... 352s Selecting previously unselected package librust-convert-case-dev:s390x. 352s Preparing to unpack .../159-librust-convert-case-dev_0.6.0-2_s390x.deb ... 352s Unpacking librust-convert-case-dev:s390x (0.6.0-2) ... 352s Selecting previously unselected package librust-semver-dev:s390x. 352s Preparing to unpack .../160-librust-semver-dev_1.0.23-1_s390x.deb ... 352s Unpacking librust-semver-dev:s390x (1.0.23-1) ... 352s Selecting previously unselected package librust-rustc-version-dev:s390x. 352s Preparing to unpack .../161-librust-rustc-version-dev_0.4.0-1_s390x.deb ... 352s Unpacking librust-rustc-version-dev:s390x (0.4.0-1) ... 352s Selecting previously unselected package librust-derive-more-0.99-dev:s390x. 352s Preparing to unpack .../162-librust-derive-more-0.99-dev_0.99.18-2_s390x.deb ... 352s Unpacking librust-derive-more-0.99-dev:s390x (0.99.18-2) ... 352s Selecting previously unselected package librust-cfg-if-0.1-dev:s390x. 352s Preparing to unpack .../163-librust-cfg-if-0.1-dev_0.1.10-3_s390x.deb ... 352s Unpacking librust-cfg-if-0.1-dev:s390x (0.1.10-3) ... 352s Selecting previously unselected package librust-blobby-dev:s390x. 352s Preparing to unpack .../164-librust-blobby-dev_0.3.1-1_s390x.deb ... 352s Unpacking librust-blobby-dev:s390x (0.3.1-1) ... 352s Selecting previously unselected package librust-typenum-dev:s390x. 352s Preparing to unpack .../165-librust-typenum-dev_1.17.0-2_s390x.deb ... 352s Unpacking librust-typenum-dev:s390x (1.17.0-2) ... 352s Selecting previously unselected package librust-zeroize-derive-dev:s390x. 352s Preparing to unpack .../166-librust-zeroize-derive-dev_1.4.2-1_s390x.deb ... 352s Unpacking librust-zeroize-derive-dev:s390x (1.4.2-1) ... 352s Selecting previously unselected package librust-zeroize-dev:s390x. 352s Preparing to unpack .../167-librust-zeroize-dev_1.8.1-1_s390x.deb ... 352s Unpacking librust-zeroize-dev:s390x (1.8.1-1) ... 352s Selecting previously unselected package librust-generic-array-dev:s390x. 352s Preparing to unpack .../168-librust-generic-array-dev_0.14.7-1_s390x.deb ... 352s Unpacking librust-generic-array-dev:s390x (0.14.7-1) ... 352s Selecting previously unselected package librust-block-buffer-dev:s390x. 352s Preparing to unpack .../169-librust-block-buffer-dev_0.10.2-2_s390x.deb ... 352s Unpacking librust-block-buffer-dev:s390x (0.10.2-2) ... 352s Selecting previously unselected package librust-const-oid-dev:s390x. 352s Preparing to unpack .../170-librust-const-oid-dev_0.9.3-1_s390x.deb ... 352s Unpacking librust-const-oid-dev:s390x (0.9.3-1) ... 352s Selecting previously unselected package librust-crypto-common-dev:s390x. 352s Preparing to unpack .../171-librust-crypto-common-dev_0.1.6-1_s390x.deb ... 352s Unpacking librust-crypto-common-dev:s390x (0.1.6-1) ... 352s Selecting previously unselected package librust-subtle-dev:s390x. 352s Preparing to unpack .../172-librust-subtle-dev_2.6.1-1_s390x.deb ... 352s Unpacking librust-subtle-dev:s390x (2.6.1-1) ... 352s Selecting previously unselected package librust-digest-dev:s390x. 352s Preparing to unpack .../173-librust-digest-dev_0.10.7-2_s390x.deb ... 352s Unpacking librust-digest-dev:s390x (0.10.7-2) ... 352s Selecting previously unselected package librust-static-assertions-dev:s390x. 352s Preparing to unpack .../174-librust-static-assertions-dev_1.1.0-1_s390x.deb ... 352s Unpacking librust-static-assertions-dev:s390x (1.1.0-1) ... 352s Selecting previously unselected package librust-twox-hash-dev:s390x. 352s Preparing to unpack .../175-librust-twox-hash-dev_1.6.3-1_s390x.deb ... 352s Unpacking librust-twox-hash-dev:s390x (1.6.3-1) ... 352s Selecting previously unselected package librust-ruzstd-dev:s390x. 352s Preparing to unpack .../176-librust-ruzstd-dev_0.5.0-1_s390x.deb ... 352s Unpacking librust-ruzstd-dev:s390x (0.5.0-1) ... 352s Selecting previously unselected package librust-object-dev:s390x. 352s Preparing to unpack .../177-librust-object-dev_0.32.2-1_s390x.deb ... 352s Unpacking librust-object-dev:s390x (0.32.2-1) ... 352s Selecting previously unselected package librust-rustc-demangle-dev:s390x. 352s Preparing to unpack .../178-librust-rustc-demangle-dev_0.1.21-1_s390x.deb ... 352s Unpacking librust-rustc-demangle-dev:s390x (0.1.21-1) ... 352s Selecting previously unselected package librust-addr2line-dev:s390x. 352s Preparing to unpack .../179-librust-addr2line-dev_0.21.0-2_s390x.deb ... 352s Unpacking librust-addr2line-dev:s390x (0.21.0-2) ... 352s Selecting previously unselected package librust-aho-corasick-dev:s390x. 352s Preparing to unpack .../180-librust-aho-corasick-dev_1.1.3-1_s390x.deb ... 352s Unpacking librust-aho-corasick-dev:s390x (1.1.3-1) ... 352s Selecting previously unselected package librust-bitflags-1-dev:s390x. 352s Preparing to unpack .../181-librust-bitflags-1-dev_1.3.2-5_s390x.deb ... 352s Unpacking librust-bitflags-1-dev:s390x (1.3.2-5) ... 352s Selecting previously unselected package librust-anes-dev:s390x. 352s Preparing to unpack .../182-librust-anes-dev_0.1.6-1_s390x.deb ... 352s Unpacking librust-anes-dev:s390x (0.1.6-1) ... 352s Selecting previously unselected package librust-anstyle-dev:s390x. 352s Preparing to unpack .../183-librust-anstyle-dev_1.0.8-1_s390x.deb ... 352s Unpacking librust-anstyle-dev:s390x (1.0.8-1) ... 352s Selecting previously unselected package librust-arrayvec-dev:s390x. 352s Preparing to unpack .../184-librust-arrayvec-dev_0.7.4-2_s390x.deb ... 352s Unpacking librust-arrayvec-dev:s390x (0.7.4-2) ... 352s Selecting previously unselected package librust-utf8parse-dev:s390x. 352s Preparing to unpack .../185-librust-utf8parse-dev_0.2.1-1_s390x.deb ... 352s Unpacking librust-utf8parse-dev:s390x (0.2.1-1) ... 352s Selecting previously unselected package librust-anstyle-parse-dev:s390x. 352s Preparing to unpack .../186-librust-anstyle-parse-dev_0.2.1-1_s390x.deb ... 352s Unpacking librust-anstyle-parse-dev:s390x (0.2.1-1) ... 352s Selecting previously unselected package librust-anstyle-query-dev:s390x. 352s Preparing to unpack .../187-librust-anstyle-query-dev_1.0.0-1_s390x.deb ... 352s Unpacking librust-anstyle-query-dev:s390x (1.0.0-1) ... 352s Selecting previously unselected package librust-colorchoice-dev:s390x. 352s Preparing to unpack .../188-librust-colorchoice-dev_1.0.0-1_s390x.deb ... 352s Unpacking librust-colorchoice-dev:s390x (1.0.0-1) ... 352s Selecting previously unselected package librust-anstream-dev:s390x. 352s Preparing to unpack .../189-librust-anstream-dev_0.6.15-1_s390x.deb ... 352s Unpacking librust-anstream-dev:s390x (0.6.15-1) ... 352s Selecting previously unselected package librust-jobserver-dev:s390x. 352s Preparing to unpack .../190-librust-jobserver-dev_0.1.32-1_s390x.deb ... 352s Unpacking librust-jobserver-dev:s390x (0.1.32-1) ... 352s Selecting previously unselected package librust-shlex-dev:s390x. 352s Preparing to unpack .../191-librust-shlex-dev_1.3.0-1_s390x.deb ... 352s Unpacking librust-shlex-dev:s390x (1.3.0-1) ... 352s Selecting previously unselected package librust-cc-dev:s390x. 352s Preparing to unpack .../192-librust-cc-dev_1.1.14-1_s390x.deb ... 352s Unpacking librust-cc-dev:s390x (1.1.14-1) ... 352s Selecting previously unselected package librust-backtrace-dev:s390x. 352s Preparing to unpack .../193-librust-backtrace-dev_0.3.69-2_s390x.deb ... 352s Unpacking librust-backtrace-dev:s390x (0.3.69-2) ... 352s Selecting previously unselected package librust-anyhow-dev:s390x. 352s Preparing to unpack .../194-librust-anyhow-dev_1.0.86-1_s390x.deb ... 352s Unpacking librust-anyhow-dev:s390x (1.0.86-1) ... 352s Selecting previously unselected package librust-bytecheck-derive-dev:s390x. 352s Preparing to unpack .../195-librust-bytecheck-derive-dev_0.6.12-1_s390x.deb ... 352s Unpacking librust-bytecheck-derive-dev:s390x (0.6.12-1) ... 352s Selecting previously unselected package librust-ptr-meta-derive-dev:s390x. 352s Preparing to unpack .../196-librust-ptr-meta-derive-dev_0.1.4-1_s390x.deb ... 352s Unpacking librust-ptr-meta-derive-dev:s390x (0.1.4-1) ... 352s Selecting previously unselected package librust-ptr-meta-dev:s390x. 352s Preparing to unpack .../197-librust-ptr-meta-dev_0.1.4-1_s390x.deb ... 352s Unpacking librust-ptr-meta-dev:s390x (0.1.4-1) ... 352s Selecting previously unselected package librust-simdutf8-dev:s390x. 352s Preparing to unpack .../198-librust-simdutf8-dev_0.1.4-4_s390x.deb ... 352s Unpacking librust-simdutf8-dev:s390x (0.1.4-4) ... 352s Selecting previously unselected package librust-bytemuck-derive-dev:s390x. 352s Preparing to unpack .../199-librust-bytemuck-derive-dev_1.5.0-2_s390x.deb ... 352s Unpacking librust-bytemuck-derive-dev:s390x (1.5.0-2) ... 352s Selecting previously unselected package librust-bytemuck-dev:s390x. 352s Preparing to unpack .../200-librust-bytemuck-dev_1.14.0-1_s390x.deb ... 352s Unpacking librust-bytemuck-dev:s390x (1.14.0-1) ... 352s Selecting previously unselected package librust-atomic-dev:s390x. 352s Preparing to unpack .../201-librust-atomic-dev_0.6.0-1_s390x.deb ... 352s Unpacking librust-atomic-dev:s390x (0.6.0-1) ... 352s Selecting previously unselected package librust-md5-asm-dev:s390x. 352s Preparing to unpack .../202-librust-md5-asm-dev_0.5.0-2_s390x.deb ... 352s Unpacking librust-md5-asm-dev:s390x (0.5.0-2) ... 352s Selecting previously unselected package librust-md-5-dev:s390x. 352s Preparing to unpack .../203-librust-md-5-dev_0.10.6-1_s390x.deb ... 352s Unpacking librust-md-5-dev:s390x (0.10.6-1) ... 352s Selecting previously unselected package librust-cpufeatures-dev:s390x. 352s Preparing to unpack .../204-librust-cpufeatures-dev_0.2.11-1_s390x.deb ... 352s Unpacking librust-cpufeatures-dev:s390x (0.2.11-1) ... 352s Selecting previously unselected package librust-sha1-asm-dev:s390x. 352s Preparing to unpack .../205-librust-sha1-asm-dev_0.5.1-2_s390x.deb ... 352s Unpacking librust-sha1-asm-dev:s390x (0.5.1-2) ... 352s Selecting previously unselected package librust-sha1-dev:s390x. 352s Preparing to unpack .../206-librust-sha1-dev_0.10.6-1_s390x.deb ... 352s Unpacking librust-sha1-dev:s390x (0.10.6-1) ... 352s Selecting previously unselected package librust-slog-dev:s390x. 352s Preparing to unpack .../207-librust-slog-dev_2.7.0-1_s390x.deb ... 352s Unpacking librust-slog-dev:s390x (2.7.0-1) ... 352s Selecting previously unselected package librust-uuid-dev:s390x. 352s Preparing to unpack .../208-librust-uuid-dev_1.10.0-1_s390x.deb ... 352s Unpacking librust-uuid-dev:s390x (1.10.0-1) ... 352s Selecting previously unselected package librust-bytecheck-dev:s390x. 352s Preparing to unpack .../209-librust-bytecheck-dev_0.6.12-1_s390x.deb ... 352s Unpacking librust-bytecheck-dev:s390x (0.6.12-1) ... 352s Selecting previously unselected package librust-autocfg-dev:s390x. 352s Preparing to unpack .../210-librust-autocfg-dev_1.1.0-1_s390x.deb ... 352s Unpacking librust-autocfg-dev:s390x (1.1.0-1) ... 352s Selecting previously unselected package librust-num-traits-dev:s390x. 352s Preparing to unpack .../211-librust-num-traits-dev_0.2.19-2_s390x.deb ... 352s Unpacking librust-num-traits-dev:s390x (0.2.19-2) ... 352s Selecting previously unselected package librust-funty-dev:s390x. 352s Preparing to unpack .../212-librust-funty-dev_2.0.0-1_s390x.deb ... 352s Unpacking librust-funty-dev:s390x (2.0.0-1) ... 352s Selecting previously unselected package librust-radium-dev:s390x. 352s Preparing to unpack .../213-librust-radium-dev_1.1.0-1_s390x.deb ... 352s Unpacking librust-radium-dev:s390x (1.1.0-1) ... 352s Selecting previously unselected package librust-tap-dev:s390x. 352s Preparing to unpack .../214-librust-tap-dev_1.0.1-1_s390x.deb ... 352s Unpacking librust-tap-dev:s390x (1.0.1-1) ... 352s Selecting previously unselected package librust-traitobject-dev:s390x. 352s Preparing to unpack .../215-librust-traitobject-dev_0.1.0-1_s390x.deb ... 352s Unpacking librust-traitobject-dev:s390x (0.1.0-1) ... 353s Selecting previously unselected package librust-unsafe-any-dev:s390x. 353s Preparing to unpack .../216-librust-unsafe-any-dev_0.4.2-2_s390x.deb ... 353s Unpacking librust-unsafe-any-dev:s390x (0.4.2-2) ... 353s Selecting previously unselected package librust-typemap-dev:s390x. 353s Preparing to unpack .../217-librust-typemap-dev_0.3.3-2_s390x.deb ... 353s Unpacking librust-typemap-dev:s390x (0.3.3-2) ... 353s Selecting previously unselected package librust-wyz-dev:s390x. 353s Preparing to unpack .../218-librust-wyz-dev_0.5.1-1_s390x.deb ... 353s Unpacking librust-wyz-dev:s390x (0.5.1-1) ... 353s Selecting previously unselected package librust-bitvec-dev:s390x. 353s Preparing to unpack .../219-librust-bitvec-dev_1.0.1-1_s390x.deb ... 353s Unpacking librust-bitvec-dev:s390x (1.0.1-1) ... 353s Selecting previously unselected package librust-bytes-dev:s390x. 353s Preparing to unpack .../220-librust-bytes-dev_1.8.0-1_s390x.deb ... 353s Unpacking librust-bytes-dev:s390x (1.8.0-1) ... 353s Selecting previously unselected package librust-rend-dev:s390x. 353s Preparing to unpack .../221-librust-rend-dev_0.4.0-1_s390x.deb ... 353s Unpacking librust-rend-dev:s390x (0.4.0-1) ... 353s Selecting previously unselected package librust-rkyv-derive-dev:s390x. 353s Preparing to unpack .../222-librust-rkyv-derive-dev_0.7.44-1_s390x.deb ... 353s Unpacking librust-rkyv-derive-dev:s390x (0.7.44-1) ... 353s Selecting previously unselected package librust-seahash-dev:s390x. 353s Preparing to unpack .../223-librust-seahash-dev_4.1.0-1_s390x.deb ... 353s Unpacking librust-seahash-dev:s390x (4.1.0-1) ... 353s Selecting previously unselected package librust-smol-str-dev:s390x. 353s Preparing to unpack .../224-librust-smol-str-dev_0.2.0-1_s390x.deb ... 353s Unpacking librust-smol-str-dev:s390x (0.2.0-1) ... 353s Selecting previously unselected package librust-tinyvec-dev:s390x. 353s Preparing to unpack .../225-librust-tinyvec-dev_1.6.0-2_s390x.deb ... 353s Unpacking librust-tinyvec-dev:s390x (1.6.0-2) ... 353s Selecting previously unselected package librust-tinyvec-macros-dev:s390x. 353s Preparing to unpack .../226-librust-tinyvec-macros-dev_0.1.0-1_s390x.deb ... 353s Unpacking librust-tinyvec-macros-dev:s390x (0.1.0-1) ... 353s Selecting previously unselected package librust-tinyvec+tinyvec-macros-dev:s390x. 353s Preparing to unpack .../227-librust-tinyvec+tinyvec-macros-dev_1.6.0-2_s390x.deb ... 353s Unpacking librust-tinyvec+tinyvec-macros-dev:s390x (1.6.0-2) ... 353s Selecting previously unselected package librust-rkyv-dev:s390x. 353s Preparing to unpack .../228-librust-rkyv-dev_0.7.44-1_s390x.deb ... 353s Unpacking librust-rkyv-dev:s390x (0.7.44-1) ... 353s Selecting previously unselected package librust-num-complex-dev:s390x. 353s Preparing to unpack .../229-librust-num-complex-dev_0.4.6-2_s390x.deb ... 353s Unpacking librust-num-complex-dev:s390x (0.4.6-2) ... 353s Selecting previously unselected package librust-approx-dev:s390x. 353s Preparing to unpack .../230-librust-approx-dev_0.5.1-1_s390x.deb ... 353s Unpacking librust-approx-dev:s390x (0.5.1-1) ... 353s Selecting previously unselected package librust-array-init-dev:s390x. 353s Preparing to unpack .../231-librust-array-init-dev_2.0.1-1_s390x.deb ... 353s Unpacking librust-array-init-dev:s390x (2.0.1-1) ... 353s Selecting previously unselected package librust-async-attributes-dev. 353s Preparing to unpack .../232-librust-async-attributes-dev_1.1.2-6_all.deb ... 353s Unpacking librust-async-attributes-dev (1.1.2-6) ... 353s Selecting previously unselected package librust-concurrent-queue-dev:s390x. 353s Preparing to unpack .../233-librust-concurrent-queue-dev_2.5.0-4_s390x.deb ... 353s Unpacking librust-concurrent-queue-dev:s390x (2.5.0-4) ... 353s Selecting previously unselected package librust-parking-dev:s390x. 353s Preparing to unpack .../234-librust-parking-dev_2.2.0-1_s390x.deb ... 353s Unpacking librust-parking-dev:s390x (2.2.0-1) ... 353s Selecting previously unselected package librust-pin-project-lite-dev:s390x. 353s Preparing to unpack .../235-librust-pin-project-lite-dev_0.2.13-1_s390x.deb ... 353s Unpacking librust-pin-project-lite-dev:s390x (0.2.13-1) ... 353s Selecting previously unselected package librust-event-listener-dev. 353s Preparing to unpack .../236-librust-event-listener-dev_5.3.1-8_all.deb ... 353s Unpacking librust-event-listener-dev (5.3.1-8) ... 353s Selecting previously unselected package librust-event-listener-strategy-dev:s390x. 353s Preparing to unpack .../237-librust-event-listener-strategy-dev_0.5.2-3_s390x.deb ... 353s Unpacking librust-event-listener-strategy-dev:s390x (0.5.2-3) ... 353s Selecting previously unselected package librust-futures-core-dev:s390x. 353s Preparing to unpack .../238-librust-futures-core-dev_0.3.30-1_s390x.deb ... 353s Unpacking librust-futures-core-dev:s390x (0.3.30-1) ... 353s Selecting previously unselected package librust-async-channel-dev. 353s Preparing to unpack .../239-librust-async-channel-dev_2.3.1-8_all.deb ... 353s Unpacking librust-async-channel-dev (2.3.1-8) ... 353s Selecting previously unselected package librust-async-task-dev. 353s Preparing to unpack .../240-librust-async-task-dev_4.7.1-3_all.deb ... 353s Unpacking librust-async-task-dev (4.7.1-3) ... 353s Selecting previously unselected package librust-fastrand-dev:s390x. 353s Preparing to unpack .../241-librust-fastrand-dev_2.1.1-1_s390x.deb ... 353s Unpacking librust-fastrand-dev:s390x (2.1.1-1) ... 353s Selecting previously unselected package librust-futures-io-dev:s390x. 353s Preparing to unpack .../242-librust-futures-io-dev_0.3.31-1_s390x.deb ... 353s Unpacking librust-futures-io-dev:s390x (0.3.31-1) ... 353s Selecting previously unselected package librust-futures-lite-dev:s390x. 353s Preparing to unpack .../243-librust-futures-lite-dev_2.3.0-2_s390x.deb ... 353s Unpacking librust-futures-lite-dev:s390x (2.3.0-2) ... 353s Selecting previously unselected package librust-slab-dev:s390x. 353s Preparing to unpack .../244-librust-slab-dev_0.4.9-1_s390x.deb ... 353s Unpacking librust-slab-dev:s390x (0.4.9-1) ... 353s Selecting previously unselected package librust-async-executor-dev. 353s Preparing to unpack .../245-librust-async-executor-dev_1.13.1-1_all.deb ... 353s Unpacking librust-async-executor-dev (1.13.1-1) ... 353s Selecting previously unselected package librust-async-lock-dev. 353s Preparing to unpack .../246-librust-async-lock-dev_3.4.0-4_all.deb ... 353s Unpacking librust-async-lock-dev (3.4.0-4) ... 353s Selecting previously unselected package librust-atomic-waker-dev:s390x. 353s Preparing to unpack .../247-librust-atomic-waker-dev_1.1.2-1_s390x.deb ... 353s Unpacking librust-atomic-waker-dev:s390x (1.1.2-1) ... 353s Selecting previously unselected package librust-tracing-attributes-dev:s390x. 353s Preparing to unpack .../248-librust-tracing-attributes-dev_0.1.27-1_s390x.deb ... 353s Unpacking librust-tracing-attributes-dev:s390x (0.1.27-1) ... 353s Selecting previously unselected package librust-valuable-derive-dev:s390x. 353s Preparing to unpack .../249-librust-valuable-derive-dev_0.1.0-1_s390x.deb ... 353s Unpacking librust-valuable-derive-dev:s390x (0.1.0-1) ... 353s Selecting previously unselected package librust-valuable-dev:s390x. 353s Preparing to unpack .../250-librust-valuable-dev_0.1.0-4_s390x.deb ... 353s Unpacking librust-valuable-dev:s390x (0.1.0-4) ... 353s Selecting previously unselected package librust-tracing-core-dev:s390x. 353s Preparing to unpack .../251-librust-tracing-core-dev_0.1.32-1_s390x.deb ... 353s Unpacking librust-tracing-core-dev:s390x (0.1.32-1) ... 353s Selecting previously unselected package librust-tracing-dev:s390x. 353s Preparing to unpack .../252-librust-tracing-dev_0.1.40-1_s390x.deb ... 353s Unpacking librust-tracing-dev:s390x (0.1.40-1) ... 353s Selecting previously unselected package librust-blocking-dev. 353s Preparing to unpack .../253-librust-blocking-dev_1.6.1-5_all.deb ... 353s Unpacking librust-blocking-dev (1.6.1-5) ... 353s Selecting previously unselected package librust-async-fs-dev. 353s Preparing to unpack .../254-librust-async-fs-dev_2.1.2-4_all.deb ... 353s Unpacking librust-async-fs-dev (2.1.2-4) ... 353s Selecting previously unselected package librust-bitflags-dev:s390x. 353s Preparing to unpack .../255-librust-bitflags-dev_2.6.0-1_s390x.deb ... 353s Unpacking librust-bitflags-dev:s390x (2.6.0-1) ... 353s Selecting previously unselected package librust-compiler-builtins+core-dev:s390x. 353s Preparing to unpack .../256-librust-compiler-builtins+core-dev_0.1.101-1_s390x.deb ... 353s Unpacking librust-compiler-builtins+core-dev:s390x (0.1.101-1) ... 353s Selecting previously unselected package librust-compiler-builtins+rustc-dep-of-std-dev:s390x. 353s Preparing to unpack .../257-librust-compiler-builtins+rustc-dep-of-std-dev_0.1.101-1_s390x.deb ... 353s Unpacking librust-compiler-builtins+rustc-dep-of-std-dev:s390x (0.1.101-1) ... 353s Selecting previously unselected package librust-errno-dev:s390x. 353s Preparing to unpack .../258-librust-errno-dev_0.3.8-1_s390x.deb ... 353s Unpacking librust-errno-dev:s390x (0.3.8-1) ... 353s Selecting previously unselected package librust-linux-raw-sys-dev:s390x. 353s Preparing to unpack .../259-librust-linux-raw-sys-dev_0.4.14-1_s390x.deb ... 353s Unpacking librust-linux-raw-sys-dev:s390x (0.4.14-1) ... 353s Selecting previously unselected package librust-rustix-dev:s390x. 353s Preparing to unpack .../260-librust-rustix-dev_0.38.37-1_s390x.deb ... 353s Unpacking librust-rustix-dev:s390x (0.38.37-1) ... 353s Selecting previously unselected package librust-polling-dev:s390x. 353s Preparing to unpack .../261-librust-polling-dev_3.4.0-1_s390x.deb ... 353s Unpacking librust-polling-dev:s390x (3.4.0-1) ... 353s Selecting previously unselected package librust-async-io-dev:s390x. 353s Preparing to unpack .../262-librust-async-io-dev_2.3.3-4_s390x.deb ... 353s Unpacking librust-async-io-dev:s390x (2.3.3-4) ... 353s Selecting previously unselected package librust-mio-dev:s390x. 353s Preparing to unpack .../263-librust-mio-dev_1.0.2-2_s390x.deb ... 353s Unpacking librust-mio-dev:s390x (1.0.2-2) ... 353s Selecting previously unselected package librust-owning-ref-dev:s390x. 353s Preparing to unpack .../264-librust-owning-ref-dev_0.4.1-1_s390x.deb ... 353s Unpacking librust-owning-ref-dev:s390x (0.4.1-1) ... 353s Selecting previously unselected package librust-scopeguard-dev:s390x. 353s Preparing to unpack .../265-librust-scopeguard-dev_1.2.0-1_s390x.deb ... 353s Unpacking librust-scopeguard-dev:s390x (1.2.0-1) ... 353s Selecting previously unselected package librust-lock-api-dev:s390x. 353s Preparing to unpack .../266-librust-lock-api-dev_0.4.12-1_s390x.deb ... 353s Unpacking librust-lock-api-dev:s390x (0.4.12-1) ... 353s Selecting previously unselected package librust-parking-lot-dev:s390x. 353s Preparing to unpack .../267-librust-parking-lot-dev_0.12.3-1_s390x.deb ... 353s Unpacking librust-parking-lot-dev:s390x (0.12.3-1) ... 353s Selecting previously unselected package librust-signal-hook-registry-dev:s390x. 353s Preparing to unpack .../268-librust-signal-hook-registry-dev_1.4.0-1_s390x.deb ... 353s Unpacking librust-signal-hook-registry-dev:s390x (1.4.0-1) ... 353s Selecting previously unselected package librust-socket2-dev:s390x. 353s Preparing to unpack .../269-librust-socket2-dev_0.5.7-1_s390x.deb ... 353s Unpacking librust-socket2-dev:s390x (0.5.7-1) ... 353s Selecting previously unselected package librust-tokio-macros-dev:s390x. 353s Preparing to unpack .../270-librust-tokio-macros-dev_2.4.0-2_s390x.deb ... 353s Unpacking librust-tokio-macros-dev:s390x (2.4.0-2) ... 353s Selecting previously unselected package librust-tokio-dev:s390x. 353s Preparing to unpack .../271-librust-tokio-dev_1.39.3-3_s390x.deb ... 353s Unpacking librust-tokio-dev:s390x (1.39.3-3) ... 353s Selecting previously unselected package librust-async-global-executor-dev:s390x. 353s Preparing to unpack .../272-librust-async-global-executor-dev_2.4.1-5_s390x.deb ... 353s Unpacking librust-async-global-executor-dev:s390x (2.4.1-5) ... 353s Selecting previously unselected package librust-async-net-dev. 353s Preparing to unpack .../273-librust-async-net-dev_2.0.0-4_all.deb ... 353s Unpacking librust-async-net-dev (2.0.0-4) ... 353s Selecting previously unselected package librust-async-signal-dev:s390x. 353s Preparing to unpack .../274-librust-async-signal-dev_0.2.10-1_s390x.deb ... 353s Unpacking librust-async-signal-dev:s390x (0.2.10-1) ... 353s Selecting previously unselected package librust-async-process-dev. 353s Preparing to unpack .../275-librust-async-process-dev_2.3.0-1_all.deb ... 353s Unpacking librust-async-process-dev (2.3.0-1) ... 353s Selecting previously unselected package librust-kv-log-macro-dev. 353s Preparing to unpack .../276-librust-kv-log-macro-dev_1.0.8-4_all.deb ... 353s Unpacking librust-kv-log-macro-dev (1.0.8-4) ... 353s Selecting previously unselected package librust-pin-utils-dev:s390x. 353s Preparing to unpack .../277-librust-pin-utils-dev_0.1.0-1_s390x.deb ... 353s Unpacking librust-pin-utils-dev:s390x (0.1.0-1) ... 353s Selecting previously unselected package librust-async-std-dev. 353s Preparing to unpack .../278-librust-async-std-dev_1.13.0-1_all.deb ... 353s Unpacking librust-async-std-dev (1.13.0-1) ... 353s Selecting previously unselected package librust-base64-dev:s390x. 353s Preparing to unpack .../279-librust-base64-dev_0.21.7-1_s390x.deb ... 353s Unpacking librust-base64-dev:s390x (0.21.7-1) ... 353s Selecting previously unselected package librust-bit-vec-dev:s390x. 353s Preparing to unpack .../280-librust-bit-vec-dev_0.6.3-1_s390x.deb ... 353s Unpacking librust-bit-vec-dev:s390x (0.6.3-1) ... 353s Selecting previously unselected package librust-bit-set-dev:s390x. 353s Preparing to unpack .../281-librust-bit-set-dev_0.5.2-1_s390x.deb ... 353s Unpacking librust-bit-set-dev:s390x (0.5.2-1) ... 353s Selecting previously unselected package librust-bit-set+std-dev:s390x. 353s Preparing to unpack .../282-librust-bit-set+std-dev_0.5.2-1_s390x.deb ... 353s Unpacking librust-bit-set+std-dev:s390x (0.5.2-1) ... 353s Selecting previously unselected package librust-regex-syntax-dev:s390x. 353s Preparing to unpack .../283-librust-regex-syntax-dev_0.8.2-1_s390x.deb ... 353s Unpacking librust-regex-syntax-dev:s390x (0.8.2-1) ... 353s Selecting previously unselected package librust-regex-automata-dev:s390x. 353s Preparing to unpack .../284-librust-regex-automata-dev_0.4.7-1_s390x.deb ... 353s Unpacking librust-regex-automata-dev:s390x (0.4.7-1) ... 354s Selecting previously unselected package librust-bstr-dev:s390x. 354s Preparing to unpack .../285-librust-bstr-dev_1.7.0-2build1_s390x.deb ... 354s Unpacking librust-bstr-dev:s390x (1.7.0-2build1) ... 354s Selecting previously unselected package librust-bumpalo-dev:s390x. 354s Preparing to unpack .../286-librust-bumpalo-dev_3.16.0-1_s390x.deb ... 354s Unpacking librust-bumpalo-dev:s390x (3.16.0-1) ... 354s Selecting previously unselected package librust-cast-dev:s390x. 354s Preparing to unpack .../287-librust-cast-dev_0.3.0-1_s390x.deb ... 354s Unpacking librust-cast-dev:s390x (0.3.0-1) ... 354s Selecting previously unselected package librust-iana-time-zone-dev:s390x. 354s Preparing to unpack .../288-librust-iana-time-zone-dev_0.1.60-1_s390x.deb ... 354s Unpacking librust-iana-time-zone-dev:s390x (0.1.60-1) ... 354s Selecting previously unselected package librust-wasm-bindgen-shared-dev:s390x. 354s Preparing to unpack .../289-librust-wasm-bindgen-shared-dev_0.2.87-1_s390x.deb ... 354s Unpacking librust-wasm-bindgen-shared-dev:s390x (0.2.87-1) ... 354s Selecting previously unselected package librust-wasm-bindgen-backend-dev:s390x. 354s Preparing to unpack .../290-librust-wasm-bindgen-backend-dev_0.2.87-1_s390x.deb ... 354s Unpacking librust-wasm-bindgen-backend-dev:s390x (0.2.87-1) ... 354s Selecting previously unselected package librust-wasm-bindgen-macro-support-dev:s390x. 354s Preparing to unpack .../291-librust-wasm-bindgen-macro-support-dev_0.2.87-1_s390x.deb ... 354s Unpacking librust-wasm-bindgen-macro-support-dev:s390x (0.2.87-1) ... 354s Selecting previously unselected package librust-wasm-bindgen-macro-dev:s390x. 354s Preparing to unpack .../292-librust-wasm-bindgen-macro-dev_0.2.87-1_s390x.deb ... 354s Unpacking librust-wasm-bindgen-macro-dev:s390x (0.2.87-1) ... 354s Selecting previously unselected package librust-wasm-bindgen-dev:s390x. 354s Preparing to unpack .../293-librust-wasm-bindgen-dev_0.2.87-1_s390x.deb ... 354s Unpacking librust-wasm-bindgen-dev:s390x (0.2.87-1) ... 354s Selecting previously unselected package librust-wasm-bindgen-macro-support+spans-dev:s390x. 354s Preparing to unpack .../294-librust-wasm-bindgen-macro-support+spans-dev_0.2.87-1_s390x.deb ... 354s Unpacking librust-wasm-bindgen-macro-support+spans-dev:s390x (0.2.87-1) ... 354s Selecting previously unselected package librust-wasm-bindgen-macro+spans-dev:s390x. 354s Preparing to unpack .../295-librust-wasm-bindgen-macro+spans-dev_0.2.87-1_s390x.deb ... 354s Unpacking librust-wasm-bindgen-macro+spans-dev:s390x (0.2.87-1) ... 354s Selecting previously unselected package librust-wasm-bindgen+spans-dev:s390x. 354s Preparing to unpack .../296-librust-wasm-bindgen+spans-dev_0.2.87-1_s390x.deb ... 354s Unpacking librust-wasm-bindgen+spans-dev:s390x (0.2.87-1) ... 354s Selecting previously unselected package librust-wasm-bindgen+default-dev:s390x. 354s Preparing to unpack .../297-librust-wasm-bindgen+default-dev_0.2.87-1_s390x.deb ... 354s Unpacking librust-wasm-bindgen+default-dev:s390x (0.2.87-1) ... 354s Selecting previously unselected package librust-js-sys-dev:s390x. 354s Preparing to unpack .../298-librust-js-sys-dev_0.3.64-1_s390x.deb ... 354s Unpacking librust-js-sys-dev:s390x (0.3.64-1) ... 354s Selecting previously unselected package librust-pure-rust-locales-dev:s390x. 354s Preparing to unpack .../299-librust-pure-rust-locales-dev_0.8.1-1_s390x.deb ... 354s Unpacking librust-pure-rust-locales-dev:s390x (0.8.1-1) ... 354s Selecting previously unselected package librust-chrono-dev:s390x. 354s Preparing to unpack .../300-librust-chrono-dev_0.4.38-2_s390x.deb ... 354s Unpacking librust-chrono-dev:s390x (0.4.38-2) ... 354s Selecting previously unselected package librust-regex-dev:s390x. 354s Preparing to unpack .../301-librust-regex-dev_1.10.6-1_s390x.deb ... 354s Unpacking librust-regex-dev:s390x (1.10.6-1) ... 354s Selecting previously unselected package librust-parse-zoneinfo-dev:s390x. 354s Preparing to unpack .../302-librust-parse-zoneinfo-dev_0.3.0-1_s390x.deb ... 354s Unpacking librust-parse-zoneinfo-dev:s390x (0.3.0-1) ... 354s Selecting previously unselected package librust-siphasher-dev:s390x. 354s Preparing to unpack .../303-librust-siphasher-dev_0.3.10-1_s390x.deb ... 354s Unpacking librust-siphasher-dev:s390x (0.3.10-1) ... 354s Selecting previously unselected package librust-phf-shared-dev:s390x. 354s Preparing to unpack .../304-librust-phf-shared-dev_0.11.2-1_s390x.deb ... 354s Unpacking librust-phf-shared-dev:s390x (0.11.2-1) ... 354s Selecting previously unselected package librust-phf-dev:s390x. 354s Preparing to unpack .../305-librust-phf-dev_0.11.2-1_s390x.deb ... 354s Unpacking librust-phf-dev:s390x (0.11.2-1) ... 354s Selecting previously unselected package librust-uncased-dev:s390x. 354s Preparing to unpack .../306-librust-uncased-dev_0.9.6-2_s390x.deb ... 354s Unpacking librust-uncased-dev:s390x (0.9.6-2) ... 354s Selecting previously unselected package librust-phf-shared+uncased-dev:s390x. 354s Preparing to unpack .../307-librust-phf-shared+uncased-dev_0.11.2-1_s390x.deb ... 354s Unpacking librust-phf-shared+uncased-dev:s390x (0.11.2-1) ... 354s Selecting previously unselected package librust-phf+uncased-dev:s390x. 354s Preparing to unpack .../308-librust-phf+uncased-dev_0.11.2-1_s390x.deb ... 354s Unpacking librust-phf+uncased-dev:s390x (0.11.2-1) ... 354s Selecting previously unselected package librust-ciborium-io-dev:s390x. 354s Preparing to unpack .../309-librust-ciborium-io-dev_0.2.2-1_s390x.deb ... 354s Unpacking librust-ciborium-io-dev:s390x (0.2.2-1) ... 354s Selecting previously unselected package librust-half-dev:s390x. 354s Preparing to unpack .../310-librust-half-dev_1.8.2-4_s390x.deb ... 354s Unpacking librust-half-dev:s390x (1.8.2-4) ... 354s Selecting previously unselected package librust-ciborium-ll-dev:s390x. 354s Preparing to unpack .../311-librust-ciborium-ll-dev_0.2.2-1_s390x.deb ... 354s Unpacking librust-ciborium-ll-dev:s390x (0.2.2-1) ... 354s Selecting previously unselected package librust-ciborium-dev:s390x. 354s Preparing to unpack .../312-librust-ciborium-dev_0.2.2-2_s390x.deb ... 354s Unpacking librust-ciborium-dev:s390x (0.2.2-2) ... 354s Selecting previously unselected package librust-clap-lex-dev:s390x. 354s Preparing to unpack .../313-librust-clap-lex-dev_0.7.2-2_s390x.deb ... 354s Unpacking librust-clap-lex-dev:s390x (0.7.2-2) ... 354s Selecting previously unselected package librust-strsim-dev:s390x. 354s Preparing to unpack .../314-librust-strsim-dev_0.11.1-1_s390x.deb ... 354s Unpacking librust-strsim-dev:s390x (0.11.1-1) ... 354s Selecting previously unselected package librust-terminal-size-dev:s390x. 354s Preparing to unpack .../315-librust-terminal-size-dev_0.3.0-2_s390x.deb ... 354s Unpacking librust-terminal-size-dev:s390x (0.3.0-2) ... 354s Selecting previously unselected package librust-unicase-dev:s390x. 354s Preparing to unpack .../316-librust-unicase-dev_2.7.0-1_s390x.deb ... 354s Unpacking librust-unicase-dev:s390x (2.7.0-1) ... 354s Selecting previously unselected package librust-unicode-width-dev:s390x. 354s Preparing to unpack .../317-librust-unicode-width-dev_0.1.14-1_s390x.deb ... 354s Unpacking librust-unicode-width-dev:s390x (0.1.14-1) ... 354s Selecting previously unselected package librust-clap-builder-dev:s390x. 354s Preparing to unpack .../318-librust-clap-builder-dev_4.5.15-2_s390x.deb ... 354s Unpacking librust-clap-builder-dev:s390x (4.5.15-2) ... 354s Selecting previously unselected package librust-heck-dev:s390x. 354s Preparing to unpack .../319-librust-heck-dev_0.4.1-1_s390x.deb ... 354s Unpacking librust-heck-dev:s390x (0.4.1-1) ... 354s Selecting previously unselected package librust-clap-derive-dev:s390x. 354s Preparing to unpack .../320-librust-clap-derive-dev_4.5.13-2_s390x.deb ... 354s Unpacking librust-clap-derive-dev:s390x (4.5.13-2) ... 354s Selecting previously unselected package librust-clap-dev:s390x. 354s Preparing to unpack .../321-librust-clap-dev_4.5.16-1_s390x.deb ... 354s Unpacking librust-clap-dev:s390x (4.5.16-1) ... 354s Selecting previously unselected package librust-csv-core-dev:s390x. 354s Preparing to unpack .../322-librust-csv-core-dev_0.1.11-1_s390x.deb ... 354s Unpacking librust-csv-core-dev:s390x (0.1.11-1) ... 354s Selecting previously unselected package librust-csv-dev:s390x. 354s Preparing to unpack .../323-librust-csv-dev_1.3.0-1_s390x.deb ... 354s Unpacking librust-csv-dev:s390x (1.3.0-1) ... 354s Selecting previously unselected package librust-futures-sink-dev:s390x. 354s Preparing to unpack .../324-librust-futures-sink-dev_0.3.31-1_s390x.deb ... 354s Unpacking librust-futures-sink-dev:s390x (0.3.31-1) ... 354s Selecting previously unselected package librust-futures-channel-dev:s390x. 354s Preparing to unpack .../325-librust-futures-channel-dev_0.3.30-1_s390x.deb ... 354s Unpacking librust-futures-channel-dev:s390x (0.3.30-1) ... 354s Selecting previously unselected package librust-futures-task-dev:s390x. 354s Preparing to unpack .../326-librust-futures-task-dev_0.3.30-1_s390x.deb ... 354s Unpacking librust-futures-task-dev:s390x (0.3.30-1) ... 354s Selecting previously unselected package librust-futures-macro-dev:s390x. 354s Preparing to unpack .../327-librust-futures-macro-dev_0.3.30-1_s390x.deb ... 354s Unpacking librust-futures-macro-dev:s390x (0.3.30-1) ... 354s Selecting previously unselected package librust-futures-util-dev:s390x. 354s Preparing to unpack .../328-librust-futures-util-dev_0.3.30-2_s390x.deb ... 354s Unpacking librust-futures-util-dev:s390x (0.3.30-2) ... 354s Selecting previously unselected package librust-num-cpus-dev:s390x. 354s Preparing to unpack .../329-librust-num-cpus-dev_1.16.0-1_s390x.deb ... 354s Unpacking librust-num-cpus-dev:s390x (1.16.0-1) ... 354s Selecting previously unselected package librust-futures-executor-dev:s390x. 354s Preparing to unpack .../330-librust-futures-executor-dev_0.3.30-1_s390x.deb ... 354s Unpacking librust-futures-executor-dev:s390x (0.3.30-1) ... 354s Selecting previously unselected package librust-futures-dev:s390x. 354s Preparing to unpack .../331-librust-futures-dev_0.3.30-2_s390x.deb ... 354s Unpacking librust-futures-dev:s390x (0.3.30-2) ... 354s Selecting previously unselected package librust-is-terminal-dev:s390x. 354s Preparing to unpack .../332-librust-is-terminal-dev_0.4.13-1_s390x.deb ... 354s Unpacking librust-is-terminal-dev:s390x (0.4.13-1) ... 354s Selecting previously unselected package librust-itertools-dev:s390x. 354s Preparing to unpack .../333-librust-itertools-dev_0.10.5-1_s390x.deb ... 354s Unpacking librust-itertools-dev:s390x (0.10.5-1) ... 354s Selecting previously unselected package librust-oorandom-dev:s390x. 354s Preparing to unpack .../334-librust-oorandom-dev_11.1.3-1_s390x.deb ... 354s Unpacking librust-oorandom-dev:s390x (11.1.3-1) ... 354s Selecting previously unselected package librust-winapi-i686-pc-windows-gnu-dev:s390x. 354s Preparing to unpack .../335-librust-winapi-i686-pc-windows-gnu-dev_0.4.0-1_s390x.deb ... 354s Unpacking librust-winapi-i686-pc-windows-gnu-dev:s390x (0.4.0-1) ... 354s Selecting previously unselected package librust-winapi-x86-64-pc-windows-gnu-dev:s390x. 354s Preparing to unpack .../336-librust-winapi-x86-64-pc-windows-gnu-dev_0.4.0-1_s390x.deb ... 354s Unpacking librust-winapi-x86-64-pc-windows-gnu-dev:s390x (0.4.0-1) ... 354s Selecting previously unselected package librust-winapi-dev:s390x. 354s Preparing to unpack .../337-librust-winapi-dev_0.3.9-1_s390x.deb ... 354s Unpacking librust-winapi-dev:s390x (0.3.9-1) ... 354s Selecting previously unselected package librust-dirs-sys-next-dev:s390x. 354s Preparing to unpack .../338-librust-dirs-sys-next-dev_0.1.1-1_s390x.deb ... 354s Unpacking librust-dirs-sys-next-dev:s390x (0.1.1-1) ... 354s Selecting previously unselected package librust-dirs-next-dev:s390x. 354s Preparing to unpack .../339-librust-dirs-next-dev_2.0.0-1_s390x.deb ... 354s Unpacking librust-dirs-next-dev:s390x (2.0.0-1) ... 354s Selecting previously unselected package librust-float-ord-dev:s390x. 354s Preparing to unpack .../340-librust-float-ord-dev_0.3.2-1_s390x.deb ... 354s Unpacking librust-float-ord-dev:s390x (0.3.2-1) ... 354s Selecting previously unselected package librust-cmake-dev:s390x. 354s Preparing to unpack .../341-librust-cmake-dev_0.1.45-1_s390x.deb ... 354s Unpacking librust-cmake-dev:s390x (0.1.45-1) ... 354s Selecting previously unselected package librust-freetype-sys-dev:s390x. 354s Preparing to unpack .../342-librust-freetype-sys-dev_0.13.1-1_s390x.deb ... 354s Unpacking librust-freetype-sys-dev:s390x (0.13.1-1) ... 354s Selecting previously unselected package librust-freetype-dev:s390x. 354s Preparing to unpack .../343-librust-freetype-dev_0.7.0-4_s390x.deb ... 354s Unpacking librust-freetype-dev:s390x (0.7.0-4) ... 354s Selecting previously unselected package librust-spin-dev:s390x. 354s Preparing to unpack .../344-librust-spin-dev_0.9.8-4_s390x.deb ... 354s Unpacking librust-spin-dev:s390x (0.9.8-4) ... 354s Selecting previously unselected package librust-lazy-static-dev:s390x. 354s Preparing to unpack .../345-librust-lazy-static-dev_1.5.0-1_s390x.deb ... 354s Unpacking librust-lazy-static-dev:s390x (1.5.0-1) ... 354s Selecting previously unselected package librust-pathfinder-simd-dev:s390x. 354s Preparing to unpack .../346-librust-pathfinder-simd-dev_0.5.2-1_s390x.deb ... 354s Unpacking librust-pathfinder-simd-dev:s390x (0.5.2-1) ... 354s Selecting previously unselected package librust-pathfinder-geometry-dev:s390x. 354s Preparing to unpack .../347-librust-pathfinder-geometry-dev_0.5.1-1_s390x.deb ... 354s Unpacking librust-pathfinder-geometry-dev:s390x (0.5.1-1) ... 355s Selecting previously unselected package librust-winapi-util-dev:s390x. 355s Preparing to unpack .../348-librust-winapi-util-dev_0.1.6-1_s390x.deb ... 355s Unpacking librust-winapi-util-dev:s390x (0.1.6-1) ... 355s Selecting previously unselected package librust-same-file-dev:s390x. 355s Preparing to unpack .../349-librust-same-file-dev_1.0.6-1_s390x.deb ... 355s Unpacking librust-same-file-dev:s390x (1.0.6-1) ... 355s Selecting previously unselected package librust-walkdir-dev:s390x. 355s Preparing to unpack .../350-librust-walkdir-dev_2.5.0-1_s390x.deb ... 355s Unpacking librust-walkdir-dev:s390x (2.5.0-1) ... 355s Selecting previously unselected package librust-const-cstr-dev:s390x. 355s Preparing to unpack .../351-librust-const-cstr-dev_0.3.0-1_s390x.deb ... 355s Unpacking librust-const-cstr-dev:s390x (0.3.0-1) ... 355s Selecting previously unselected package librust-libloading-dev:s390x. 355s Preparing to unpack .../352-librust-libloading-dev_0.8.5-1_s390x.deb ... 355s Unpacking librust-libloading-dev:s390x (0.8.5-1) ... 355s Selecting previously unselected package librust-dlib-dev:s390x. 355s Preparing to unpack .../353-librust-dlib-dev_0.5.2-2_s390x.deb ... 355s Unpacking librust-dlib-dev:s390x (0.5.2-2) ... 355s Selecting previously unselected package librust-yeslogic-fontconfig-sys-dev:s390x. 355s Preparing to unpack .../354-librust-yeslogic-fontconfig-sys-dev_3.0.1-1_s390x.deb ... 355s Unpacking librust-yeslogic-fontconfig-sys-dev:s390x (3.0.1-1) ... 355s Selecting previously unselected package librust-font-kit-dev:s390x. 355s Preparing to unpack .../355-librust-font-kit-dev_0.11.0-2_s390x.deb ... 355s Unpacking librust-font-kit-dev:s390x (0.11.0-2) ... 355s Selecting previously unselected package librust-color-quant-dev:s390x. 355s Preparing to unpack .../356-librust-color-quant-dev_1.1.0-1_s390x.deb ... 355s Unpacking librust-color-quant-dev:s390x (1.1.0-1) ... 355s Selecting previously unselected package librust-weezl-dev:s390x. 355s Preparing to unpack .../357-librust-weezl-dev_0.1.5-1_s390x.deb ... 355s Unpacking librust-weezl-dev:s390x (0.1.5-1) ... 355s Selecting previously unselected package librust-gif-dev:s390x. 355s Preparing to unpack .../358-librust-gif-dev_0.11.3-1_s390x.deb ... 355s Unpacking librust-gif-dev:s390x (0.11.3-1) ... 355s Selecting previously unselected package librust-jpeg-decoder-dev:s390x. 355s Preparing to unpack .../359-librust-jpeg-decoder-dev_0.3.0-1_s390x.deb ... 355s Unpacking librust-jpeg-decoder-dev:s390x (0.3.0-1) ... 355s Selecting previously unselected package librust-num-integer-dev:s390x. 355s Preparing to unpack .../360-librust-num-integer-dev_0.1.46-1_s390x.deb ... 355s Unpacking librust-num-integer-dev:s390x (0.1.46-1) ... 355s Selecting previously unselected package librust-humantime-dev:s390x. 355s Preparing to unpack .../361-librust-humantime-dev_2.1.0-1_s390x.deb ... 355s Unpacking librust-humantime-dev:s390x (2.1.0-1) ... 355s Selecting previously unselected package librust-termcolor-dev:s390x. 355s Preparing to unpack .../362-librust-termcolor-dev_1.4.1-1_s390x.deb ... 355s Unpacking librust-termcolor-dev:s390x (1.4.1-1) ... 355s Selecting previously unselected package librust-env-logger-dev:s390x. 355s Preparing to unpack .../363-librust-env-logger-dev_0.10.2-2_s390x.deb ... 355s Unpacking librust-env-logger-dev:s390x (0.10.2-2) ... 355s Selecting previously unselected package librust-quickcheck-dev:s390x. 355s Preparing to unpack .../364-librust-quickcheck-dev_1.0.3-3_s390x.deb ... 355s Unpacking librust-quickcheck-dev:s390x (1.0.3-3) ... 355s Selecting previously unselected package librust-num-bigint-dev:s390x. 355s Preparing to unpack .../365-librust-num-bigint-dev_0.4.6-1_s390x.deb ... 355s Unpacking librust-num-bigint-dev:s390x (0.4.6-1) ... 355s Selecting previously unselected package librust-num-rational-dev:s390x. 355s Preparing to unpack .../366-librust-num-rational-dev_0.4.2-1_s390x.deb ... 355s Unpacking librust-num-rational-dev:s390x (0.4.2-1) ... 355s Selecting previously unselected package librust-png-dev:s390x. 355s Preparing to unpack .../367-librust-png-dev_0.17.7-3_s390x.deb ... 355s Unpacking librust-png-dev:s390x (0.17.7-3) ... 355s Selecting previously unselected package librust-qoi-dev:s390x. 355s Preparing to unpack .../368-librust-qoi-dev_0.4.1-2_s390x.deb ... 355s Unpacking librust-qoi-dev:s390x (0.4.1-2) ... 355s Selecting previously unselected package librust-tiff-dev:s390x. 355s Preparing to unpack .../369-librust-tiff-dev_0.9.0-1_s390x.deb ... 355s Unpacking librust-tiff-dev:s390x (0.9.0-1) ... 355s Selecting previously unselected package libsharpyuv0:s390x. 355s Preparing to unpack .../370-libsharpyuv0_1.4.0-0.1_s390x.deb ... 355s Unpacking libsharpyuv0:s390x (1.4.0-0.1) ... 355s Selecting previously unselected package libwebp7:s390x. 355s Preparing to unpack .../371-libwebp7_1.4.0-0.1_s390x.deb ... 355s Unpacking libwebp7:s390x (1.4.0-0.1) ... 355s Selecting previously unselected package libwebpdemux2:s390x. 355s Preparing to unpack .../372-libwebpdemux2_1.4.0-0.1_s390x.deb ... 355s Unpacking libwebpdemux2:s390x (1.4.0-0.1) ... 355s Selecting previously unselected package libwebpmux3:s390x. 355s Preparing to unpack .../373-libwebpmux3_1.4.0-0.1_s390x.deb ... 355s Unpacking libwebpmux3:s390x (1.4.0-0.1) ... 355s Selecting previously unselected package libwebpdecoder3:s390x. 355s Preparing to unpack .../374-libwebpdecoder3_1.4.0-0.1_s390x.deb ... 355s Unpacking libwebpdecoder3:s390x (1.4.0-0.1) ... 355s Selecting previously unselected package libsharpyuv-dev:s390x. 355s Preparing to unpack .../375-libsharpyuv-dev_1.4.0-0.1_s390x.deb ... 355s Unpacking libsharpyuv-dev:s390x (1.4.0-0.1) ... 355s Selecting previously unselected package libwebp-dev:s390x. 355s Preparing to unpack .../376-libwebp-dev_1.4.0-0.1_s390x.deb ... 355s Unpacking libwebp-dev:s390x (1.4.0-0.1) ... 355s Selecting previously unselected package librust-libwebp-sys-dev:s390x. 355s Preparing to unpack .../377-librust-libwebp-sys-dev_0.9.5-1build1_s390x.deb ... 355s Unpacking librust-libwebp-sys-dev:s390x (0.9.5-1build1) ... 355s Selecting previously unselected package librust-webp-dev:s390x. 355s Preparing to unpack .../378-librust-webp-dev_0.2.6-1_s390x.deb ... 355s Unpacking librust-webp-dev:s390x (0.2.6-1) ... 355s Selecting previously unselected package librust-image-dev:s390x. 355s Preparing to unpack .../379-librust-image-dev_0.24.7-2_s390x.deb ... 355s Unpacking librust-image-dev:s390x (0.24.7-2) ... 355s Selecting previously unselected package librust-plotters-backend-dev:s390x. 355s Preparing to unpack .../380-librust-plotters-backend-dev_0.3.7-1_s390x.deb ... 355s Unpacking librust-plotters-backend-dev:s390x (0.3.7-1) ... 355s Selecting previously unselected package librust-plotters-bitmap-dev:s390x. 355s Preparing to unpack .../381-librust-plotters-bitmap-dev_0.3.3-3_s390x.deb ... 355s Unpacking librust-plotters-bitmap-dev:s390x (0.3.3-3) ... 355s Selecting previously unselected package librust-plotters-svg-dev:s390x. 355s Preparing to unpack .../382-librust-plotters-svg-dev_0.3.5-1_s390x.deb ... 355s Unpacking librust-plotters-svg-dev:s390x (0.3.5-1) ... 355s Selecting previously unselected package librust-web-sys-dev:s390x. 355s Preparing to unpack .../383-librust-web-sys-dev_0.3.64-2_s390x.deb ... 355s Unpacking librust-web-sys-dev:s390x (0.3.64-2) ... 355s Selecting previously unselected package librust-plotters-dev:s390x. 355s Preparing to unpack .../384-librust-plotters-dev_0.3.5-4_s390x.deb ... 355s Unpacking librust-plotters-dev:s390x (0.3.5-4) ... 355s Selecting previously unselected package librust-smol-dev. 355s Preparing to unpack .../385-librust-smol-dev_2.0.2-1_all.deb ... 355s Unpacking librust-smol-dev (2.0.2-1) ... 355s Selecting previously unselected package librust-tinytemplate-dev:s390x. 355s Preparing to unpack .../386-librust-tinytemplate-dev_1.2.1-1_s390x.deb ... 355s Unpacking librust-tinytemplate-dev:s390x (1.2.1-1) ... 355s Selecting previously unselected package librust-criterion-dev. 355s Preparing to unpack .../387-librust-criterion-dev_0.5.1-6_all.deb ... 355s Unpacking librust-criterion-dev (0.5.1-6) ... 355s Selecting previously unselected package librust-phf-generator-dev:s390x. 355s Preparing to unpack .../388-librust-phf-generator-dev_0.11.2-2_s390x.deb ... 355s Unpacking librust-phf-generator-dev:s390x (0.11.2-2) ... 355s Selecting previously unselected package librust-phf-codegen-dev:s390x. 355s Preparing to unpack .../389-librust-phf-codegen-dev_0.11.2-1_s390x.deb ... 355s Unpacking librust-phf-codegen-dev:s390x (0.11.2-1) ... 355s Selecting previously unselected package librust-chrono-tz-build-dev:s390x. 355s Preparing to unpack .../390-librust-chrono-tz-build-dev_0.2.1-1_s390x.deb ... 355s Unpacking librust-chrono-tz-build-dev:s390x (0.2.1-1) ... 355s Selecting previously unselected package librust-chrono-tz-dev:s390x. 355s Preparing to unpack .../391-librust-chrono-tz-dev_0.8.6-2_s390x.deb ... 355s Unpacking librust-chrono-tz-dev:s390x (0.8.6-2) ... 355s Selecting previously unselected package librust-ctor-dev:s390x. 355s Preparing to unpack .../392-librust-ctor-dev_0.1.26-1_s390x.deb ... 355s Unpacking librust-ctor-dev:s390x (0.1.26-1) ... 355s Selecting previously unselected package librust-powerfmt-macros-dev:s390x. 355s Preparing to unpack .../393-librust-powerfmt-macros-dev_0.1.0-1_s390x.deb ... 355s Unpacking librust-powerfmt-macros-dev:s390x (0.1.0-1) ... 355s Selecting previously unselected package librust-powerfmt-dev:s390x. 355s Preparing to unpack .../394-librust-powerfmt-dev_0.2.0-1_s390x.deb ... 355s Unpacking librust-powerfmt-dev:s390x (0.2.0-1) ... 355s Selecting previously unselected package librust-deranged-dev:s390x. 355s Preparing to unpack .../395-librust-deranged-dev_0.3.11-1_s390x.deb ... 355s Unpacking librust-deranged-dev:s390x (0.3.11-1) ... 355s Selecting previously unselected package librust-eui48-dev:s390x. 355s Preparing to unpack .../396-librust-eui48-dev_1.1.0-2_s390x.deb ... 355s Unpacking librust-eui48-dev:s390x (1.1.0-2) ... 355s Selecting previously unselected package librust-indenter-dev:s390x. 355s Preparing to unpack .../397-librust-indenter-dev_0.3.3-1_s390x.deb ... 355s Unpacking librust-indenter-dev:s390x (0.3.3-1) ... 355s Selecting previously unselected package librust-eyre-dev:s390x. 355s Preparing to unpack .../398-librust-eyre-dev_0.6.12-1_s390x.deb ... 355s Unpacking librust-eyre-dev:s390x (0.6.12-1) ... 355s Selecting previously unselected package librust-eyre+default-dev:s390x. 355s Preparing to unpack .../399-librust-eyre+default-dev_0.6.12-1_s390x.deb ... 355s Unpacking librust-eyre+default-dev:s390x (0.6.12-1) ... 355s Selecting previously unselected package librust-fancy-regex-dev:s390x. 355s Preparing to unpack .../400-librust-fancy-regex-dev_0.11.0-2_s390x.deb ... 355s Unpacking librust-fancy-regex-dev:s390x (0.11.0-2) ... 355s Selecting previously unselected package librust-fnv-dev:s390x. 355s Preparing to unpack .../401-librust-fnv-dev_1.0.7-1_s390x.deb ... 355s Unpacking librust-fnv-dev:s390x (1.0.7-1) ... 355s Selecting previously unselected package librust-geo-types-dev:s390x. 355s Preparing to unpack .../402-librust-geo-types-dev_0.7.11-2_s390x.deb ... 355s Unpacking librust-geo-types-dev:s390x (0.7.11-2) ... 355s Selecting previously unselected package librust-ghost-dev:s390x. 355s Preparing to unpack .../403-librust-ghost-dev_0.1.5-1_s390x.deb ... 355s Unpacking librust-ghost-dev:s390x (0.1.5-1) ... 355s Selecting previously unselected package librust-hmac-dev:s390x. 355s Preparing to unpack .../404-librust-hmac-dev_0.12.1-1_s390x.deb ... 355s Unpacking librust-hmac-dev:s390x (0.12.1-1) ... 356s Selecting previously unselected package librust-indoc-dev:s390x. 356s Preparing to unpack .../405-librust-indoc-dev_2.0.5-1_s390x.deb ... 356s Unpacking librust-indoc-dev:s390x (2.0.5-1) ... 356s Selecting previously unselected package librust-inventory-dev:s390x. 356s Preparing to unpack .../406-librust-inventory-dev_0.3.2-1_s390x.deb ... 356s Unpacking librust-inventory-dev:s390x (0.3.2-1) ... 356s Selecting previously unselected package librust-memoffset-dev:s390x. 356s Preparing to unpack .../407-librust-memoffset-dev_0.8.0-1_s390x.deb ... 356s Unpacking librust-memoffset-dev:s390x (0.8.0-1) ... 356s Selecting previously unselected package librust-num-conv-dev:s390x. 356s Preparing to unpack .../408-librust-num-conv-dev_0.1.0-1_s390x.deb ... 356s Unpacking librust-num-conv-dev:s390x (0.1.0-1) ... 356s Selecting previously unselected package librust-num-threads-dev:s390x. 356s Preparing to unpack .../409-librust-num-threads-dev_0.1.7-1_s390x.deb ... 356s Unpacking librust-num-threads-dev:s390x (0.1.7-1) ... 356s Selecting previously unselected package librust-postgres-derive-dev:s390x. 356s Preparing to unpack .../410-librust-postgres-derive-dev_0.4.5-1_s390x.deb ... 356s Unpacking librust-postgres-derive-dev:s390x (0.4.5-1) ... 356s Selecting previously unselected package librust-sha2-asm-dev:s390x. 356s Preparing to unpack .../411-librust-sha2-asm-dev_0.6.2-2_s390x.deb ... 356s Unpacking librust-sha2-asm-dev:s390x (0.6.2-2) ... 356s Selecting previously unselected package librust-sha2-dev:s390x. 356s Preparing to unpack .../412-librust-sha2-dev_0.10.8-1_s390x.deb ... 356s Unpacking librust-sha2-dev:s390x (0.10.8-1) ... 356s Selecting previously unselected package librust-unicode-bidi-dev:s390x. 356s Preparing to unpack .../413-librust-unicode-bidi-dev_0.3.13-1_s390x.deb ... 356s Unpacking librust-unicode-bidi-dev:s390x (0.3.13-1) ... 356s Selecting previously unselected package librust-unicode-normalization-dev:s390x. 356s Preparing to unpack .../414-librust-unicode-normalization-dev_0.1.22-1_s390x.deb ... 356s Unpacking librust-unicode-normalization-dev:s390x (0.1.22-1) ... 356s Selecting previously unselected package librust-stringprep-dev:s390x. 356s Preparing to unpack .../415-librust-stringprep-dev_0.1.2-1_s390x.deb ... 356s Unpacking librust-stringprep-dev:s390x (0.1.2-1) ... 356s Selecting previously unselected package librust-postgres-protocol-dev:s390x. 356s Preparing to unpack .../416-librust-postgres-protocol-dev_0.6.6-2_s390x.deb ... 356s Unpacking librust-postgres-protocol-dev:s390x (0.6.6-2) ... 356s Selecting previously unselected package librust-time-core-dev:s390x. 356s Preparing to unpack .../417-librust-time-core-dev_0.1.2-1_s390x.deb ... 356s Unpacking librust-time-core-dev:s390x (0.1.2-1) ... 356s Selecting previously unselected package librust-time-macros-dev:s390x. 356s Preparing to unpack .../418-librust-time-macros-dev_0.2.16-1_s390x.deb ... 356s Unpacking librust-time-macros-dev:s390x (0.2.16-1) ... 356s Selecting previously unselected package librust-time-dev:s390x. 356s Preparing to unpack .../419-librust-time-dev_0.3.36-2_s390x.deb ... 356s Unpacking librust-time-dev:s390x (0.3.36-2) ... 356s Selecting previously unselected package librust-postgres-types-dev:s390x. 356s Preparing to unpack .../420-librust-postgres-types-dev_0.2.6-2_s390x.deb ... 356s Unpacking librust-postgres-types-dev:s390x (0.2.6-2) ... 356s Selecting previously unselected package librust-rand-xorshift-dev:s390x. 356s Preparing to unpack .../421-librust-rand-xorshift-dev_0.3.0-2_s390x.deb ... 356s Unpacking librust-rand-xorshift-dev:s390x (0.3.0-2) ... 356s Selecting previously unselected package librust-quick-error-dev:s390x. 356s Preparing to unpack .../422-librust-quick-error-dev_2.0.1-1_s390x.deb ... 356s Unpacking librust-quick-error-dev:s390x (2.0.1-1) ... 356s Selecting previously unselected package librust-tempfile-dev:s390x. 356s Preparing to unpack .../423-librust-tempfile-dev_3.13.0-1_s390x.deb ... 356s Unpacking librust-tempfile-dev:s390x (3.13.0-1) ... 356s Selecting previously unselected package librust-rusty-fork-dev:s390x. 356s Preparing to unpack .../424-librust-rusty-fork-dev_0.3.0-1_s390x.deb ... 356s Unpacking librust-rusty-fork-dev:s390x (0.3.0-1) ... 356s Selecting previously unselected package librust-wait-timeout-dev:s390x. 356s Preparing to unpack .../425-librust-wait-timeout-dev_0.2.0-1_s390x.deb ... 356s Unpacking librust-wait-timeout-dev:s390x (0.2.0-1) ... 356s Selecting previously unselected package librust-rusty-fork+wait-timeout-dev:s390x. 356s Preparing to unpack .../426-librust-rusty-fork+wait-timeout-dev_0.3.0-1_s390x.deb ... 356s Unpacking librust-rusty-fork+wait-timeout-dev:s390x (0.3.0-1) ... 356s Selecting previously unselected package librust-unarray-dev:s390x. 356s Preparing to unpack .../427-librust-unarray-dev_0.1.4-1_s390x.deb ... 356s Unpacking librust-unarray-dev:s390x (0.1.4-1) ... 356s Selecting previously unselected package librust-proptest-dev:s390x. 356s Preparing to unpack .../428-librust-proptest-dev_1.5.0-2_s390x.deb ... 356s Unpacking librust-proptest-dev:s390x (1.5.0-2) ... 356s Selecting previously unselected package llvm-19-runtime. 356s Preparing to unpack .../429-llvm-19-runtime_1%3a19.1.2-1ubuntu1_s390x.deb ... 356s Unpacking llvm-19-runtime (1:19.1.2-1ubuntu1) ... 356s Selecting previously unselected package llvm-runtime:s390x. 356s Preparing to unpack .../430-llvm-runtime_1%3a19.0-60~exp1_s390x.deb ... 356s Unpacking llvm-runtime:s390x (1:19.0-60~exp1) ... 356s Selecting previously unselected package llvm-19-linker-tools. 356s Preparing to unpack .../431-llvm-19-linker-tools_1%3a19.1.2-1ubuntu1_s390x.deb ... 356s Unpacking llvm-19-linker-tools (1:19.1.2-1ubuntu1) ... 356s Selecting previously unselected package libpfm4:s390x. 356s Preparing to unpack .../432-libpfm4_4.13.0+git83-g91970fe-1_s390x.deb ... 356s Unpacking libpfm4:s390x (4.13.0+git83-g91970fe-1) ... 356s Selecting previously unselected package llvm-19. 356s Preparing to unpack .../433-llvm-19_1%3a19.1.2-1ubuntu1_s390x.deb ... 356s Unpacking llvm-19 (1:19.1.2-1ubuntu1) ... 356s Selecting previously unselected package llvm. 356s Preparing to unpack .../434-llvm_1%3a19.0-60~exp1_s390x.deb ... 356s Unpacking llvm (1:19.0-60~exp1) ... 356s Selecting previously unselected package binutils-mingw-w64-x86-64. 356s Preparing to unpack .../435-binutils-mingw-w64-x86-64_2.43.1-4ubuntu1+12_s390x.deb ... 356s Unpacking binutils-mingw-w64-x86-64 (2.43.1-4ubuntu1+12) ... 357s Selecting previously unselected package binutils-mingw-w64-i686. 357s Preparing to unpack .../436-binutils-mingw-w64-i686_2.43.1-4ubuntu1+12_s390x.deb ... 357s Unpacking binutils-mingw-w64-i686 (2.43.1-4ubuntu1+12) ... 357s Selecting previously unselected package librust-python3-dll-a-dev:s390x. 357s Preparing to unpack .../437-librust-python3-dll-a-dev_0.2.10-1_s390x.deb ... 357s Unpacking librust-python3-dll-a-dev:s390x (0.2.10-1) ... 357s Selecting previously unselected package librust-target-lexicon-dev:s390x. 357s Preparing to unpack .../438-librust-target-lexicon-dev_0.12.14-1_s390x.deb ... 357s Unpacking librust-target-lexicon-dev:s390x (0.12.14-1) ... 357s Selecting previously unselected package librust-pyo3-build-config-dev:s390x. 357s Preparing to unpack .../439-librust-pyo3-build-config-dev_0.22.6-1_s390x.deb ... 357s Unpacking librust-pyo3-build-config-dev:s390x (0.22.6-1) ... 357s Selecting previously unselected package python3.12-dev. 357s Preparing to unpack .../440-python3.12-dev_3.12.7-3_s390x.deb ... 357s Unpacking python3.12-dev (3.12.7-3) ... 357s Selecting previously unselected package librust-pyo3-ffi-dev:s390x. 357s Preparing to unpack .../441-librust-pyo3-ffi-dev_0.22.6-1build1_s390x.deb ... 357s Unpacking librust-pyo3-ffi-dev:s390x (0.22.6-1build1) ... 357s Selecting previously unselected package librust-pyo3-macros-backend-dev:s390x. 357s Preparing to unpack .../442-librust-pyo3-macros-backend-dev_0.22.6-1_s390x.deb ... 357s Unpacking librust-pyo3-macros-backend-dev:s390x (0.22.6-1) ... 357s Selecting previously unselected package librust-pyo3-macros-dev:s390x. 357s Preparing to unpack .../443-librust-pyo3-macros-dev_0.22.6-1_s390x.deb ... 357s Unpacking librust-pyo3-macros-dev:s390x (0.22.6-1) ... 357s Selecting previously unselected package librust-rust-decimal-dev:s390x. 357s Preparing to unpack .../444-librust-rust-decimal-dev_1.36.0-1_s390x.deb ... 357s Unpacking librust-rust-decimal-dev:s390x (1.36.0-1) ... 357s Selecting previously unselected package librust-unindent-dev:s390x. 357s Preparing to unpack .../445-librust-unindent-dev_0.2.3-1_s390x.deb ... 357s Unpacking librust-unindent-dev:s390x (0.2.3-1) ... 357s Selecting previously unselected package librust-pyo3-dev:s390x. 357s Preparing to unpack .../446-librust-pyo3-dev_0.22.6-1_s390x.deb ... 357s Unpacking librust-pyo3-dev:s390x (0.22.6-1) ... 357s Selecting previously unselected package librust-rustc-hash-dev:s390x. 357s Preparing to unpack .../447-librust-rustc-hash-dev_1.1.0-1_s390x.deb ... 357s Unpacking librust-rustc-hash-dev:s390x (1.1.0-1) ... 357s Selecting previously unselected package pybuild-plugin-autopkgtest. 357s Preparing to unpack .../448-pybuild-plugin-autopkgtest_6.20241024_all.deb ... 357s Unpacking pybuild-plugin-autopkgtest (6.20241024) ... 357s Selecting previously unselected package python3-packaging. 357s Preparing to unpack .../449-python3-packaging_24.2-1_all.deb ... 357s Unpacking python3-packaging (24.2-1) ... 357s Selecting previously unselected package python3-pyproject-hooks. 357s Preparing to unpack .../450-python3-pyproject-hooks_1.2.0-1_all.deb ... 357s Unpacking python3-pyproject-hooks (1.2.0-1) ... 357s Selecting previously unselected package python3-toml. 357s Preparing to unpack .../451-python3-toml_0.10.2-1_all.deb ... 357s Unpacking python3-toml (0.10.2-1) ... 357s Selecting previously unselected package python3-wheel. 357s Preparing to unpack .../452-python3-wheel_0.45.1-1_all.deb ... 357s Unpacking python3-wheel (0.45.1-1) ... 357s Selecting previously unselected package python3-build. 357s Preparing to unpack .../453-python3-build_1.2.2-1_all.deb ... 357s Unpacking python3-build (1.2.2-1) ... 357s Selecting previously unselected package python3-installer. 357s Preparing to unpack .../454-python3-installer_0.7.0+dfsg1-3_all.deb ... 357s Unpacking python3-installer (0.7.0+dfsg1-3) ... 357s Selecting previously unselected package pybuild-plugin-pyproject. 357s Preparing to unpack .../455-pybuild-plugin-pyproject_6.20241024_all.deb ... 357s Unpacking pybuild-plugin-pyproject (6.20241024) ... 357s Selecting previously unselected package python3.13. 357s Preparing to unpack .../456-python3.13_3.13.0-2_s390x.deb ... 357s Unpacking python3.13 (3.13.0-2) ... 357s Selecting previously unselected package python3-all. 357s Preparing to unpack .../457-python3-all_3.12.7-1_s390x.deb ... 357s Unpacking python3-all (3.12.7-1) ... 357s Selecting previously unselected package python3-dateutil. 357s Preparing to unpack .../458-python3-dateutil_2.9.0-3_all.deb ... 357s Unpacking python3-dateutil (2.9.0-3) ... 357s Selecting previously unselected package python3-sortedcontainers. 357s Preparing to unpack .../459-python3-sortedcontainers_2.4.0-2_all.deb ... 357s Unpacking python3-sortedcontainers (2.4.0-2) ... 357s Selecting previously unselected package python3-hypothesis. 357s Preparing to unpack .../460-python3-hypothesis_6.119.3-1_all.deb ... 357s Unpacking python3-hypothesis (6.119.3-1) ... 357s Selecting previously unselected package python3-iniconfig. 357s Preparing to unpack .../461-python3-iniconfig_1.1.1-2_all.deb ... 357s Unpacking python3-iniconfig (1.1.1-2) ... 357s Selecting previously unselected package python3-pluggy. 357s Preparing to unpack .../462-python3-pluggy_1.5.0-1_all.deb ... 357s Unpacking python3-pluggy (1.5.0-1) ... 357s Selecting previously unselected package python3-pytest. 357s Preparing to unpack .../463-python3-pytest_8.3.3-1_all.deb ... 357s Unpacking python3-pytest (8.3.3-1) ... 357s Selecting previously unselected package python3-regex. 357s Preparing to unpack .../464-python3-regex_0.1.20240724-1build1_s390x.deb ... 357s Unpacking python3-regex (0.1.20240724-1build1) ... 357s Selecting previously unselected package python3-semantic-version. 357s Preparing to unpack .../465-python3-semantic-version_2.10.0-2_all.deb ... 357s Unpacking python3-semantic-version (2.10.0-2) ... 357s Selecting previously unselected package rustc. 357s Preparing to unpack .../466-rustc_1.80.1ubuntu2_s390x.deb ... 357s Unpacking rustc (1.80.1ubuntu2) ... 357s Selecting previously unselected package cargo. 357s Preparing to unpack .../467-cargo_1.80.1ubuntu2_s390x.deb ... 357s Unpacking cargo (1.80.1ubuntu2) ... 357s Selecting previously unselected package python3-setuptools-rust. 357s Preparing to unpack .../468-python3-setuptools-rust_1.9.0+dfsg-2_all.deb ... 357s Unpacking python3-setuptools-rust (1.9.0+dfsg-2) ... 357s Selecting previously unselected package python3-tiktoken. 357s Preparing to unpack .../469-python3-tiktoken_0.8.0-1build1_s390x.deb ... 357s Unpacking python3-tiktoken (0.8.0-1build1) ... 357s Setting up dh-python (6.20241024) ... 357s Setting up librust-ciborium-io-dev:s390x (0.2.2-1) ... 357s Setting up librust-crossbeam-utils-dev:s390x (0.8.19-1) ... 357s Setting up librust-parking-dev:s390x (2.2.0-1) ... 357s Setting up librust-ppv-lite86-dev:s390x (0.2.16-1) ... 357s Setting up python3-iniconfig (1.1.1-2) ... 357s Setting up libsharpyuv0:s390x (1.4.0-0.1) ... 357s Setting up librust-pin-utils-dev:s390x (0.1.0-1) ... 357s Setting up librust-fnv-dev:s390x (1.0.7-1) ... 357s Setting up librust-unindent-dev:s390x (0.2.3-1) ... 357s Setting up librust-quick-error-dev:s390x (2.0.1-1) ... 357s Setting up librust-traitobject-dev:s390x (0.1.0-1) ... 357s Setting up librust-either-dev:s390x (1.13.0-1) ... 357s Setting up binutils-mingw-w64-x86-64 (2.43.1-4ubuntu1+12) ... 357s Setting up librust-adler-dev:s390x (1.0.2-2) ... 357s Setting up librust-version-check-dev:s390x (0.9.5-1) ... 357s Setting up librust-base64-dev:s390x (0.21.7-1) ... 357s Setting up librust-indoc-dev:s390x (2.0.5-1) ... 357s Setting up librust-anstyle-dev:s390x (1.0.8-1) ... 357s Setting up librust-winapi-i686-pc-windows-gnu-dev:s390x (0.4.0-1) ... 357s Setting up librust-futures-task-dev:s390x (0.3.30-1) ... 357s Setting up librust-rustc-hash-dev:s390x (1.1.0-1) ... 357s Setting up librust-wasm-bindgen-shared-dev:s390x (0.2.87-1) ... 357s Setting up libarchive-zip-perl (1.68-1) ... 357s Setting up librust-colorchoice-dev:s390x (1.0.0-1) ... 357s Setting up librust-fastrand-dev:s390x (2.1.1-1) ... 357s Setting up libdebhelper-perl (13.20ubuntu1) ... 357s Setting up librust-unsafe-any-dev:s390x (0.4.2-2) ... 357s Setting up librust-tinyvec-macros-dev:s390x (0.1.0-1) ... 357s Setting up librust-libm-dev:s390x (0.2.8-1) ... 357s Setting up librust-strsim-dev:s390x (0.11.1-1) ... 358s Setting up libwebpdecoder3:s390x (1.4.0-0.1) ... 358s Setting up m4 (1.4.19-4build1) ... 358s Setting up librust-rustc-demangle-dev:s390x (0.1.21-1) ... 358s Setting up librust-const-cstr-dev:s390x (0.3.0-1) ... 358s Setting up librust-fallible-iterator-dev:s390x (0.3.0-2) ... 358s Setting up librust-ryu-dev:s390x (1.0.15-1) ... 358s Setting up python3-sortedcontainers (2.4.0-2) ... 358s Setting up librust-humantime-dev:s390x (2.1.0-1) ... 358s Setting up librust-anstyle-query-dev:s390x (1.0.0-1) ... 358s Setting up librust-cast-dev:s390x (0.3.0-1) ... 358s Setting up libgomp1:s390x (14.2.0-8ubuntu1) ... 358s Setting up librust-subtle-dev:s390x (2.6.1-1) ... 358s Setting up librust-simdutf8-dev:s390x (0.1.4-4) ... 358s Setting up librust-atomic-waker-dev:s390x (1.1.2-1) ... 358s Setting up librust-miniz-oxide-dev:s390x (0.7.1-1) ... 358s Setting up librust-pin-project-lite-dev:s390x (0.2.13-1) ... 358s Setting up python3-wheel (0.45.1-1) ... 358s Setting up librust-unicode-segmentation-dev:s390x (1.11.0-1) ... 358s Setting up librust-typemap-dev:s390x (0.3.3-2) ... 358s Setting up libpython3.13-minimal:s390x (3.13.0-2) ... 358s Setting up librust-compiler-builtins-dev:s390x (0.1.101-1) ... 358s Setting up librust-weezl-dev:s390x (0.1.5-1) ... 358s Setting up librust-utf8parse-dev:s390x (0.2.1-1) ... 358s Setting up librust-crossbeam-epoch-dev:s390x (0.9.18-1) ... 358s Setting up autotools-dev (20220109.1) ... 358s Setting up librust-tap-dev:s390x (1.0.1-1) ... 358s Setting up python3-packaging (24.2-1) ... 358s Setting up librust-array-init-dev:s390x (2.0.1-1) ... 358s Setting up libpkgconf3:s390x (1.8.1-4) ... 358s Setting up libpfm4:s390x (4.13.0+git83-g91970fe-1) ... 358s Setting up librust-oorandom-dev:s390x (11.1.3-1) ... 358s Setting up libexpat1-dev:s390x (2.6.4-1) ... 358s Setting up python3-pyproject-hooks (1.2.0-1) ... 358s Setting up libfreetype6:s390x (2.13.3+dfsg-1) ... 358s Setting up librust-rustc-std-workspace-core-dev:s390x (1.0.0-1) ... 358s Setting up librust-funty-dev:s390x (2.0.0-1) ... 358s Setting up librust-futures-io-dev:s390x (0.3.31-1) ... 358s Setting up librust-typenum-dev:s390x (1.17.0-2) ... 358s Setting up uuid-dev:s390x (2.40.2-1ubuntu1) ... 358s Setting up librust-core-maths-dev:s390x (0.1.0-2) ... 358s Setting up librust-stable-deref-trait-dev:s390x (1.2.0-1) ... 358s Setting up librust-critical-section-dev:s390x (1.1.3-1) ... 358s Setting up librust-scopeguard-dev:s390x (1.2.0-1) ... 358s Setting up librust-iana-time-zone-dev:s390x (0.1.60-1) ... 358s Setting up fonts-dejavu-mono (2.37-8) ... 358s Setting up libmpc3:s390x (1.3.1-1build2) ... 358s Setting up librust-rand-core-dev:s390x (0.6.4-2) ... 358s Setting up python3-semantic-version (2.10.0-2) ... 358s Setting up autopoint (0.22.5-2) ... 358s Setting up libjsoncpp25:s390x (1.9.5-6build1) ... 358s Setting up fonts-dejavu-core (2.37-8) ... 358s Setting up librust-seahash-dev:s390x (4.1.0-1) ... 358s Setting up pkgconf-bin (1.8.1-4) ... 358s Setting up librust-ab-glyph-rasterizer-dev:s390x (0.1.7-1) ... 358s Setting up binutils-mingw-w64-i686 (2.43.1-4ubuntu1+12) ... 358s Setting up librust-time-core-dev:s390x (0.1.2-1) ... 358s Setting up python3-regex (0.1.20240724-1build1) ... 359s Setting up librust-crunchy-dev:s390x (0.2.2-1) ... 359s Setting up python3-toml (0.10.2-1) ... 359s Setting up librust-unicase-dev:s390x (2.7.0-1) ... 359s Setting up librust-unicode-width-dev:s390x (0.1.14-1) ... 359s Setting up python3-installer (0.7.0+dfsg1-3) ... 359s Setting up autoconf (2.72-3) ... 359s Setting up python3-pluggy (1.5.0-1) ... 359s Setting up libwebp7:s390x (1.4.0-0.1) ... 359s Setting up libubsan1:s390x (14.2.0-8ubuntu1) ... 359s Setting up zlib1g-dev:s390x (1:1.3.dfsg+really1.3.1-1ubuntu1) ... 359s Setting up librust-unicode-ident-dev:s390x (1.0.13-1) ... 359s Setting up librust-equivalent-dev:s390x (1.0.1-1) ... 359s Setting up dwz (0.15-1build6) ... 359s Setting up librust-bitflags-1-dev:s390x (1.3.2-5) ... 359s Setting up librust-uncased-dev:s390x (0.9.6-2) ... 359s Setting up librust-slog-dev:s390x (2.7.0-1) ... 359s Setting up python3-tiktoken (0.8.0-1build1) ... 359s Setting up librust-pure-rust-locales-dev:s390x (0.8.1-1) ... 359s Setting up librhash0:s390x (1.4.3-3build1) ... 359s Setting up libasan8:s390x (14.2.0-8ubuntu1) ... 359s Setting up librust-ttf-parser-dev:s390x (0.24.1-1) ... 359s Setting up librust-cfg-if-dev:s390x (1.0.0-1) ... 359s Setting up debugedit (1:5.1-1) ... 359s Setting up librust-color-quant-dev:s390x (1.1.0-1) ... 359s Setting up python3.13-minimal (3.13.0-2) ... 360s Setting up python3-dateutil (2.9.0-3) ... 360s Setting up librust-blobby-dev:s390x (0.3.1-1) ... 360s Setting up cmake-data (3.30.3-1) ... 360s Setting up llvm-19-linker-tools (1:19.1.2-1ubuntu1) ... 360s Setting up librust-byteorder-dev:s390x (1.5.0-1) ... 360s Setting up librust-static-assertions-dev:s390x (1.1.0-1) ... 360s Setting up librust-compiler-builtins+core-dev:s390x (0.1.101-1) ... 360s Setting up librust-float-ord-dev:s390x (0.3.2-1) ... 360s Setting up librust-autocfg-dev:s390x (1.1.0-1) ... 360s Setting up libisl23:s390x (0.27-1) ... 360s Setting up librust-time-macros-dev:s390x (0.2.16-1) ... 360s Setting up llvm-19-runtime (1:19.1.2-1ubuntu1) ... 360s Setting up librust-futures-sink-dev:s390x (0.3.31-1) ... 360s Setting up python3-build (1.2.2-1) ... 360s Setting up libsharpyuv-dev:s390x (1.4.0-0.1) ... 360s Setting up librust-cfg-if-0.1-dev:s390x (0.1.10-3) ... 360s Setting up librust-tinyvec-dev:s390x (1.6.0-2) ... 360s Setting up libwebpmux3:s390x (1.4.0-0.1) ... 360s Setting up librust-plotters-backend-dev:s390x (0.3.7-1) ... 360s Setting up librust-shlex-dev:s390x (1.3.0-1) ... 360s Setting up libpython3.13-stdlib:s390x (3.13.0-2) ... 360s Setting up librust-indenter-dev:s390x (0.3.3-1) ... 360s Setting up librust-cpp-demangle-dev:s390x (0.4.0-1) ... 360s Setting up librust-winapi-x86-64-pc-windows-gnu-dev:s390x (0.4.0-1) ... 360s Setting up libcc1-0:s390x (14.2.0-8ubuntu1) ... 361s Setting up libbrotli-dev:s390x (1.1.0-2build3) ... 361s Setting up libitm1:s390x (14.2.0-8ubuntu1) ... 361s Setting up librust-clap-lex-dev:s390x (0.7.2-2) ... 361s Setting up libhttp-parser2.9:s390x (2.9.4-6build1) ... 361s Setting up librust-unarray-dev:s390x (0.1.4-1) ... 361s Setting up libstd-rust-1.80:s390x (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 361s Setting up librust-itertools-dev:s390x (0.10.5-1) ... 361s Setting up librust-heck-dev:s390x (0.4.1-1) ... 361s Setting up libbz2-dev:s390x (1.0.8-6) ... 361s Setting up librust-num-conv-dev:s390x (0.1.0-1) ... 361s Setting up libpython3.13:s390x (3.13.0-2) ... 361s Setting up automake (1:1.16.5-1.3ubuntu1) ... 361s update-alternatives: using /usr/bin/automake-1.16 to provide /usr/bin/automake (automake) in auto mode 361s Setting up libfile-stripnondeterminism-perl (1.14.0-1) ... 361s Setting up librust-owned-ttf-parser-dev:s390x (0.24.0-1) ... 361s Setting up librust-crossbeam-epoch+std-dev:s390x (0.9.18-1) ... 361s Setting up librust-libc-dev:s390x (0.2.161-1) ... 361s Setting up librust-is-terminal-dev:s390x (0.4.13-1) ... 361s Setting up gettext (0.22.5-2) ... 361s Setting up librust-gif-dev:s390x (0.11.3-1) ... 361s Setting up librust-crossbeam-deque-dev:s390x (0.8.5-1) ... 361s Setting up librust-tiny-keccak-dev:s390x (2.0.2-1) ... 361s Setting up python3.13 (3.13.0-2) ... 361s Setting up librust-linux-raw-sys-dev:s390x (0.4.14-1) ... 361s Setting up pybuild-plugin-pyproject (6.20241024) ... 361s Setting up fontconfig-config (2.15.0-1.1ubuntu2) ... 362s Setting up librust-getrandom-dev:s390x (0.2.12-1) ... 362s Setting up python3-pytest (8.3.3-1) ... 362s Setting up librust-libloading-dev:s390x (0.8.5-1) ... 362s Setting up librust-socket2-dev:s390x (0.5.7-1) ... 362s Setting up librust-memmap2-dev:s390x (0.9.3-1) ... 362s Setting up libwebpdemux2:s390x (1.4.0-0.1) ... 362s Setting up python3-hypothesis (6.119.3-1) ... 363s Setting up librust-ab-glyph-rasterizer+libm-dev:s390x (0.1.7-1) ... 363s Setting up libpng-dev:s390x (1.6.44-2) ... 363s Setting up librust-tinyvec+tinyvec-macros-dev:s390x (1.6.0-2) ... 363s Setting up librust-owning-ref-dev:s390x (0.4.1-1) ... 363s Setting up librust-num-cpus-dev:s390x (1.16.0-1) ... 363s Setting up librust-memoffset-dev:s390x (0.8.0-1) ... 363s Setting up python3-all (3.12.7-1) ... 363s Setting up librust-cpufeatures-dev:s390x (0.2.11-1) ... 363s Setting up libpython3.12-dev:s390x (3.12.7-3) ... 363s Setting up librust-proc-macro2-dev:s390x (1.0.86-1) ... 363s Setting up librust-compiler-builtins+rustc-dep-of-std-dev:s390x (0.1.101-1) ... 363s Setting up librust-rayon-core-dev:s390x (1.12.1-1) ... 363s Setting up librust-winapi-dev:s390x (0.3.9-1) ... 363s Setting up pkgconf:s390x (1.8.1-4) ... 363s Setting up librust-ab-glyph-dev:s390x (0.2.28-1) ... 363s Setting up libstd-rust-1.80-dev:s390x (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 363s Setting up libfreetype-dev:s390x (2.13.3+dfsg-1) ... 363s Setting up intltool-debian (0.35.0+20060710.6) ... 363s Setting up librust-rand-core+getrandom-dev:s390x (0.6.4-2) ... 363s Setting up librust-rand-xorshift-dev:s390x (0.3.0-2) ... 363s Setting up librust-signal-hook-registry-dev:s390x (1.4.0-1) ... 363s Setting up libwebp-dev:s390x (1.4.0-0.1) ... 363s Setting up librust-errno-dev:s390x (0.3.8-1) ... 363s Setting up librust-anes-dev:s390x (0.1.6-1) ... 363s Setting up libpython3.13-dev:s390x (3.13.0-2) ... 363s Setting up llvm-runtime:s390x (1:19.0-60~exp1) ... 363s Setting up python3.12-dev (3.12.7-3) ... 363s Setting up librust-jobserver-dev:s390x (0.1.32-1) ... 363s Setting up pkg-config:s390x (1.8.1-4) ... 363s Setting up cpp-14-s390x-linux-gnu (14.2.0-8ubuntu1) ... 363s Setting up cpp-14 (14.2.0-8ubuntu1) ... 363s Setting up dh-strip-nondeterminism (1.14.0-1) ... 363s Setting up librust-crc32fast-dev:s390x (1.4.2-1) ... 363s Setting up librust-num-traits-dev:s390x (0.2.19-2) ... 363s Setting up librust-winapi-util-dev:s390x (0.1.6-1) ... 363s Setting up librust-wait-timeout-dev:s390x (0.2.0-1) ... 363s Setting up cmake (3.30.3-1) ... 363s Setting up libgit2-1.7:s390x (1.7.2+ds-1ubuntu3) ... 363s Setting up llvm-19 (1:19.1.2-1ubuntu1) ... 363s Setting up libgcc-14-dev:s390x (14.2.0-8ubuntu1) ... 363s Setting up librust-same-file-dev:s390x (1.0.6-1) ... 363s Setting up librust-rayon-dev:s390x (1.10.0-1) ... 363s Setting up librust-termcolor-dev:s390x (1.4.1-1) ... 363s Setting up librust-pkg-config-dev:s390x (0.3.27-1) ... 363s Setting up libstdc++-14-dev:s390x (14.2.0-8ubuntu1) ... 363s Setting up librust-jpeg-decoder-dev:s390x (0.3.0-1) ... 363s Setting up librust-dirs-sys-next-dev:s390x (0.1.1-1) ... 363s Setting up librust-num-integer-dev:s390x (0.1.46-1) ... 363s Setting up librust-dirs-next-dev:s390x (2.0.0-1) ... 363s Setting up librust-num-threads-dev:s390x (0.1.7-1) ... 363s Setting up libpython3-dev:s390x (3.12.7-1) ... 363s Setting up librust-dlib-dev:s390x (0.5.2-2) ... 363s Setting up cpp-s390x-linux-gnu (4:14.1.0-2ubuntu1) ... 363s Setting up librust-libwebp-sys-dev:s390x (0.9.5-1build1) ... 363s Setting up po-debconf (1.0.21+nmu1) ... 363s Setting up librust-quote-dev:s390x (1.0.37-1) ... 363s Setting up librust-libz-sys-dev:s390x (1.1.20-1) ... 363s Setting up librust-syn-dev:s390x (2.0.85-1) ... 363s Setting up librust-rand-core+std-dev:s390x (0.6.4-2) ... 363s Setting up librust-powerfmt-macros-dev:s390x (0.1.0-1) ... 363s Setting up gcc-14-s390x-linux-gnu (14.2.0-8ubuntu1) ... 363s Setting up gcc-s390x-linux-gnu (4:14.1.0-2ubuntu1) ... 363s Setting up librust-powerfmt-dev:s390x (0.2.0-1) ... 363s Setting up librust-sval-derive-dev:s390x (2.6.1-2) ... 363s Setting up libpython3-all-dev:s390x (3.12.7-1) ... 363s Setting up librust-cc-dev:s390x (1.1.14-1) ... 363s Setting up g++-14-s390x-linux-gnu (14.2.0-8ubuntu1) ... 363s Setting up librust-zeroize-derive-dev:s390x (1.4.2-1) ... 363s Setting up llvm (1:19.0-60~exp1) ... 363s Setting up librust-postgres-derive-dev:s390x (0.4.5-1) ... 363s Setting up librust-syn-1-dev:s390x (1.0.109-2) ... 363s Setting up librust-clap-derive-dev:s390x (4.5.13-2) ... 363s Setting up librust-bytecheck-derive-dev:s390x (0.6.12-1) ... 363s Setting up librust-no-panic-dev:s390x (0.1.13-1) ... 363s Setting up cpp (4:14.1.0-2ubuntu1) ... 363s Setting up librust-serde-derive-dev:s390x (1.0.210-1) ... 363s Setting up librust-walkdir-dev:s390x (2.5.0-1) ... 363s Setting up librust-zerocopy-derive-dev:s390x (0.7.32-2) ... 363s Setting up librust-sha1-asm-dev:s390x (0.5.1-2) ... 363s Setting up librust-valuable-derive-dev:s390x (0.1.0-1) ... 363s Setting up librust-ghost-dev:s390x (0.1.5-1) ... 363s Setting up librust-serde-dev:s390x (1.0.210-2) ... 363s Setting up librust-bytemuck-derive-dev:s390x (1.5.0-2) ... 363s Setting up librust-derive-arbitrary-dev:s390x (1.3.2-1) ... 363s Setting up librust-allocator-api2-dev:s390x (0.2.16-1) ... 363s Setting up librust-cmake-dev:s390x (0.1.45-1) ... 363s Setting up librust-async-attributes-dev (1.1.2-6) ... 363s Setting up librust-rand-chacha-dev:s390x (0.3.1-2) ... 363s Setting up librust-futures-macro-dev:s390x (0.3.30-1) ... 363s Setting up librust-ctor-dev:s390x (0.1.26-1) ... 363s Setting up librust-unicode-bidi-dev:s390x (0.3.13-1) ... 363s Setting up librust-tracing-attributes-dev:s390x (0.1.27-1) ... 363s Setting up librust-ptr-meta-derive-dev:s390x (0.1.4-1) ... 363s Setting up librust-serde-fmt-dev (1.0.3-3) ... 363s Setting up librust-sha2-asm-dev:s390x (0.6.2-2) ... 363s Setting up librust-portable-atomic-dev:s390x (1.9.0-4) ... 363s Setting up librust-tokio-macros-dev:s390x (2.4.0-2) ... 363s Setting up librust-flate2-dev:s390x (1.0.34-1) ... 363s Setting up librust-freetype-sys-dev:s390x (0.13.1-1) ... 363s Setting up librust-lock-api-dev:s390x (0.4.12-1) ... 363s Setting up g++-s390x-linux-gnu (4:14.1.0-2ubuntu1) ... 363s Setting up librust-ptr-meta-dev:s390x (0.1.4-1) ... 363s Setting up librust-inventory-dev:s390x (0.3.2-1) ... 363s Setting up librust-sval-dev:s390x (2.6.1-2) ... 363s Setting up librust-itoa-dev:s390x (1.0.9-1) ... 363s Setting up gcc-14 (14.2.0-8ubuntu1) ... 363s Setting up librust-bytes-dev:s390x (1.8.0-1) ... 363s Setting up librust-bumpalo-dev:s390x (3.16.0-1) ... 363s Setting up librust-python3-dll-a-dev:s390x (0.2.10-1) ... 363s Setting up librust-siphasher-dev:s390x (0.3.10-1) ... 363s Setting up librust-rand-core+serde-dev:s390x (0.6.4-2) ... 363s Setting up librust-sval-ref-dev:s390x (2.6.1-1) ... 363s Setting up librust-rkyv-derive-dev:s390x (0.7.44-1) ... 363s Setting up librust-zerocopy-dev:s390x (0.7.32-1) ... 363s Setting up librust-md5-asm-dev:s390x (0.5.0-2) ... 363s Setting up librust-semver-dev:s390x (1.0.23-1) ... 363s Setting up librust-freetype-dev:s390x (0.7.0-4) ... 363s Setting up librust-bytemuck-dev:s390x (1.14.0-1) ... 363s Setting up librust-bit-vec-dev:s390x (0.6.3-1) ... 363s Setting up librust-zeroize-dev:s390x (1.8.1-1) ... 363s Setting up librust-slab-dev:s390x (0.4.9-1) ... 363s Setting up librust-arbitrary-dev:s390x (1.3.2-1) ... 363s Setting up librust-valuable-dev:s390x (0.1.0-4) ... 363s Setting up librust-target-lexicon-dev:s390x (0.12.14-1) ... 363s Setting up librust-serde-test-dev:s390x (1.0.171-1) ... 363s Setting up librust-bit-set-dev:s390x (0.5.2-1) ... 363s Setting up librust-concurrent-queue-dev:s390x (2.5.0-4) ... 363s Setting up g++-14 (14.2.0-8ubuntu1) ... 363s Setting up librust-erased-serde-dev:s390x (0.3.31-1) ... 363s Setting up librust-radium-dev:s390x (1.1.0-1) ... 363s Setting up librust-bit-set+std-dev:s390x (0.5.2-1) ... 363s Setting up librust-phf-shared-dev:s390x (0.11.2-1) ... 363s Setting up librust-tiff-dev:s390x (0.9.0-1) ... 363s Setting up librust-smol-str-dev:s390x (0.2.0-1) ... 363s Setting up librust-atomic-dev:s390x (0.6.0-1) ... 363s Setting up librust-generic-array-dev:s390x (0.14.7-1) ... 363s Setting up librust-half-dev:s390x (1.8.2-4) ... 363s Setting up librust-phf-dev:s390x (0.11.2-1) ... 363s Setting up librust-spin-dev:s390x (0.9.8-4) ... 363s Setting up librust-sval-dynamic-dev:s390x (2.6.1-1) ... 363s Setting up librust-qoi-dev:s390x (0.4.1-2) ... 363s Setting up librust-async-task-dev (4.7.1-3) ... 363s Setting up librust-crypto-common-dev:s390x (0.1.6-1) ... 363s Setting up librust-ciborium-ll-dev:s390x (0.2.2-1) ... 363s Setting up librust-futures-core-dev:s390x (0.3.30-1) ... 363s Setting up librust-lazy-static-dev:s390x (1.5.0-1) ... 363s Setting up libtool (2.4.7-8) ... 363s Setting up librust-sval-buffer-dev:s390x (2.6.1-1) ... 363s Setting up librust-arrayvec-dev:s390x (0.7.4-2) ... 363s Setting up librust-png-dev:s390x (0.17.7-3) ... 363s Setting up librust-rustc-version-dev:s390x (0.4.0-1) ... 363s Setting up librust-event-listener-dev (5.3.1-8) ... 363s Setting up librust-smallvec-dev:s390x (1.13.2-1) ... 363s Setting up librust-sval-fmt-dev:s390x (2.6.1-1) ... 363s Setting up librust-const-oid-dev:s390x (0.9.3-1) ... 363s Setting up gcc (4:14.1.0-2ubuntu1) ... 363s Setting up librust-anstyle-parse-dev:s390x (0.2.1-1) ... 363s Setting up rustc-1.80 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 363s Setting up dh-autoreconf (20) ... 363s Setting up librust-ciborium-dev:s390x (0.2.2-2) ... 363s Setting up librust-block-buffer-dev:s390x (0.10.2-2) ... 363s Setting up librust-pathfinder-simd-dev:s390x (0.5.2-1) ... 363s Setting up librust-unicode-normalization-dev:s390x (0.1.22-1) ... 363s Setting up librust-anstream-dev:s390x (0.6.15-1) ... 363s Setting up librust-bitflags-dev:s390x (2.6.0-1) ... 363s Setting up librust-regex-syntax-dev:s390x (0.8.2-1) ... 363s Setting up g++ (4:14.1.0-2ubuntu1) ... 363s update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode 363s Setting up rustc (1.80.1ubuntu2) ... 363s Setting up librust-parking-lot-core-dev:s390x (0.9.10-1) ... 363s Setting up build-essential (12.10ubuntu1) ... 363s Setting up librust-futures-channel-dev:s390x (0.3.30-1) ... 363s Setting up cargo-1.80 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 363s Setting up librust-once-cell-dev:s390x (1.20.2-1) ... 363s Setting up librust-pyo3-build-config-dev:s390x (0.22.6-1) ... 363s Setting up librust-phf-shared+uncased-dev:s390x (0.11.2-1) ... 363s Setting up librust-digest-dev:s390x (0.10.7-2) ... 363s Setting up librust-md-5-dev:s390x (0.10.6-1) ... 363s Setting up librust-sval-serde-dev:s390x (2.6.1-1) ... 363s Setting up librust-parking-lot-dev:s390x (0.12.3-1) ... 363s Setting up librust-event-listener-strategy-dev:s390x (0.5.2-3) ... 363s Setting up librust-pyo3-macros-backend-dev:s390x (0.22.6-1) ... 363s Setting up librust-pyo3-ffi-dev:s390x (0.22.6-1build1) ... 363s Setting up librust-const-random-macro-dev:s390x (0.1.16-2) ... 363s Setting up librust-const-random-dev:s390x (0.1.17-2) ... 363s Setting up librust-pyo3-macros-dev:s390x (0.22.6-1) ... 363s Setting up librust-sha1-dev:s390x (0.10.6-1) ... 363s Setting up debhelper (13.20ubuntu1) ... 363s Setting up librust-ahash-dev (0.8.11-8) ... 363s Setting up librust-async-channel-dev (2.3.1-8) ... 363s Setting up librust-stringprep-dev:s390x (0.1.2-1) ... 363s Setting up librust-tracing-core-dev:s390x (0.1.32-1) ... 363s Setting up cargo (1.80.1ubuntu2) ... 363s Setting up librust-async-lock-dev (3.4.0-4) ... 363s Setting up python3-setuptools-rust (1.9.0+dfsg-2) ... 363s Setting up librust-eyre-dev:s390x (0.6.12-1) ... 363s Setting up librust-sha2-dev:s390x (0.10.8-1) ... 363s Setting up librust-hmac-dev:s390x (0.12.1-1) ... 363s Setting up librust-rustix-dev:s390x (0.38.37-1) ... 363s Setting up librust-wyz-dev:s390x (0.5.1-1) ... 363s Setting up librust-bitvec-dev:s390x (1.0.1-1) ... 363s Setting up librust-phf+uncased-dev:s390x (0.11.2-1) ... 363s Setting up librust-value-bag-sval2-dev:s390x (1.9.0-1) ... 363s Setting up librust-tempfile-dev:s390x (3.13.0-1) ... 363s Setting up librust-eyre+default-dev:s390x (0.6.12-1) ... 363s Setting up pybuild-plugin-autopkgtest (6.20241024) ... 363s Setting up librust-rusty-fork-dev:s390x (0.3.0-1) ... 363s Setting up librust-hashbrown-dev:s390x (0.14.5-5) ... 363s Setting up librust-rusty-fork+wait-timeout-dev:s390x (0.3.0-1) ... 363s Setting up librust-terminal-size-dev:s390x (0.3.0-2) ... 363s Setting up librust-indexmap-dev:s390x (2.2.6-1) ... 363s Setting up librust-gimli-dev:s390x (0.28.1-2) ... 363s Setting up librust-webp-dev:s390x (0.2.6-1) ... 363s Setting up librust-memchr-dev:s390x (2.7.4-1) ... 363s Setting up librust-futures-util-dev:s390x (0.3.30-2) ... 363s Setting up librust-csv-core-dev:s390x (0.1.11-1) ... 363s Setting up librust-futures-lite-dev:s390x (2.3.0-2) ... 363s Setting up librust-csv-dev:s390x (1.3.0-1) ... 363s Setting up librust-serde-json-dev:s390x (1.0.128-1) ... 363s Setting up librust-async-executor-dev (1.13.1-1) ... 363s Setting up librust-futures-executor-dev:s390x (0.3.30-1) ... 363s Setting up librust-value-bag-serde1-dev:s390x (1.9.0-1) ... 363s Setting up librust-tinytemplate-dev:s390x (1.2.1-1) ... 363s Setting up librust-futures-dev:s390x (0.3.30-2) ... 363s Setting up librust-value-bag-dev:s390x (1.9.0-1) ... 363s Setting up librust-log-dev:s390x (0.4.22-1) ... 363s Setting up librust-kv-log-macro-dev (1.0.8-4) ... 363s Setting up librust-pathfinder-geometry-dev:s390x (0.5.1-1) ... 363s Setting up librust-tracing-dev:s390x (0.1.40-1) ... 363s Setting up librust-polling-dev:s390x (3.4.0-1) ... 363s Setting up librust-aho-corasick-dev:s390x (1.1.3-1) ... 363s Setting up librust-async-io-dev:s390x (2.3.3-4) ... 363s Setting up librust-blocking-dev (1.6.1-5) ... 363s Setting up librust-async-net-dev (2.0.0-4) ... 363s Setting up librust-rand-dev:s390x (0.8.5-1) ... 363s Setting up librust-mio-dev:s390x (1.0.2-2) ... 363s Setting up librust-wasm-bindgen-backend-dev:s390x (0.2.87-1) ... 363s Setting up librust-twox-hash-dev:s390x (1.6.3-1) ... 363s Setting up librust-proptest-dev:s390x (1.5.0-2) ... 363s Setting up librust-wasm-bindgen-macro-support-dev:s390x (0.2.87-1) ... 363s Setting up librust-regex-automata-dev:s390x (0.4.7-1) ... 363s Setting up librust-wasm-bindgen-macro-support+spans-dev:s390x (0.2.87-1) ... 363s Setting up librust-wasm-bindgen-macro-dev:s390x (0.2.87-1) ... 363s Setting up librust-uuid-dev:s390x (1.10.0-1) ... 363s Setting up librust-bstr-dev:s390x (1.7.0-2build1) ... 363s Setting up librust-async-signal-dev:s390x (0.2.10-1) ... 363s Setting up librust-bytecheck-dev:s390x (0.6.12-1) ... 363s Setting up librust-postgres-protocol-dev:s390x (0.6.6-2) ... 363s Setting up librust-async-fs-dev (2.1.2-4) ... 363s Setting up librust-wasm-bindgen-dev:s390x (0.2.87-1) ... 363s Setting up librust-convert-case-dev:s390x (0.6.0-2) ... 363s Setting up librust-regex-dev:s390x (1.10.6-1) ... 363s Setting up librust-fancy-regex-dev:s390x (0.11.0-2) ... 363s Setting up librust-async-process-dev (2.3.0-1) ... 363s Setting up librust-wasm-bindgen-macro+spans-dev:s390x (0.2.87-1) ... 363s Setting up librust-rend-dev:s390x (0.4.0-1) ... 363s Setting up librust-derive-more-0.99-dev:s390x (0.99.18-2) ... 363s Setting up librust-env-logger-dev:s390x (0.10.2-2) ... 363s Setting up librust-wasm-bindgen+spans-dev:s390x (0.2.87-1) ... 363s Setting up librust-wasm-bindgen+default-dev:s390x (0.2.87-1) ... 363s Setting up librust-rkyv-dev:s390x (0.7.44-1) ... 363s Setting up librust-eui48-dev:s390x (1.1.0-2) ... 363s Setting up librust-parse-zoneinfo-dev:s390x (0.3.0-1) ... 363s Setting up librust-smol-dev (2.0.2-1) ... 363s Setting up librust-js-sys-dev:s390x (0.3.64-1) ... 363s Setting up librust-num-complex-dev:s390x (0.4.6-2) ... 363s Setting up librust-approx-dev:s390x (0.5.1-1) ... 363s Setting up librust-ruzstd-dev:s390x (0.5.0-1) ... 363s Setting up librust-web-sys-dev:s390x (0.3.64-2) ... 363s Setting up librust-quickcheck-dev:s390x (1.0.3-3) ... 363s Setting up librust-geo-types-dev:s390x (0.7.11-2) ... 363s Setting up librust-deranged-dev:s390x (0.3.11-1) ... 363s Setting up librust-num-bigint-dev:s390x (0.4.6-1) ... 363s Setting up librust-num-rational-dev:s390x (0.4.2-1) ... 363s Setting up librust-chrono-dev:s390x (0.4.38-2) ... 363s Setting up librust-object-dev:s390x (0.32.2-1) ... 363s Setting up librust-image-dev:s390x (0.24.7-2) ... 363s Setting up librust-time-dev:s390x (0.3.36-2) ... 363s Setting up librust-plotters-bitmap-dev:s390x (0.3.3-3) ... 363s Setting up librust-postgres-types-dev:s390x (0.2.6-2) ... 363s Setting up librust-addr2line-dev:s390x (0.21.0-2) ... 363s Setting up librust-plotters-svg-dev:s390x (0.3.5-1) ... 363s Setting up librust-rust-decimal-dev:s390x (1.36.0-1) ... 363s Setting up librust-backtrace-dev:s390x (0.3.69-2) ... 363s Setting up librust-tokio-dev:s390x (1.39.3-3) ... 363s Setting up librust-async-global-executor-dev:s390x (2.4.1-5) ... 363s Setting up librust-clap-builder-dev:s390x (4.5.15-2) ... 363s Setting up librust-clap-dev:s390x (4.5.16-1) ... 363s Setting up librust-async-std-dev (1.13.0-1) ... 363s Setting up librust-anyhow-dev:s390x (1.0.86-1) ... 363s Processing triggers for sgml-base (1.31) ... 363s Setting up libfontconfig1:s390x (2.15.0-1.1ubuntu2) ... 363s Processing triggers for install-info (7.1.1-1) ... 363s Setting up libfontconfig-dev:s390x (2.15.0-1.1ubuntu2) ... 363s Processing triggers for libc-bin (2.40-1ubuntu3) ... 363s Processing triggers for systemd (256.5-2ubuntu4) ... 363s Processing triggers for man-db (2.13.0-1) ... 364s Setting up librust-yeslogic-fontconfig-sys-dev:s390x (3.0.1-1) ... 364s Setting up librust-font-kit-dev:s390x (0.11.0-2) ... 364s Setting up librust-plotters-dev:s390x (0.3.5-4) ... 364s Setting up librust-criterion-dev (0.5.1-6) ... 364s Setting up librust-phf-generator-dev:s390x (0.11.2-2) ... 364s Setting up librust-phf-codegen-dev:s390x (0.11.2-1) ... 364s Setting up librust-chrono-tz-build-dev:s390x (0.2.1-1) ... 364s Setting up librust-chrono-tz-dev:s390x (0.8.6-2) ... 364s Setting up librust-pyo3-dev:s390x (0.22.6-1) ... 365s autopkgtest [21:43:21]: test pybuild-autopkgtest: pybuild-autopkgtest 365s autopkgtest [21:43:21]: test pybuild-autopkgtest: [----------------------- 365s pybuild-autopkgtest 366s I: pybuild base:311: cd /tmp/autopkgtest.74YOef/autopkgtest_tmp/build; python3.13 -m pytest tests 366s ============================= test session starts ============================== 366s platform linux -- Python 3.13.0, pytest-8.3.3, pluggy-1.5.0 366s rootdir: /tmp/autopkgtest.74YOef/autopkgtest_tmp/build 366s configfile: pyproject.toml 366s plugins: typeguard-4.4.1, hypothesis-6.119.3 366s collected 30 items 366s 933s tests/test_encoding.py FFFFFFFFFFFFFFFFFFFFFF [ 73%] 934s tests/test_misc.py F. [ 80%] 937s tests/test_offsets.py FF [ 86%] 938s tests/test_pickle.py F [ 90%] 940s tests/test_simple_public.py FF. [100%] 940s 940s =================================== FAILURES =================================== 940s _________________________________ test_simple __________________________________ 940s 940s self = 940s 940s def _new_conn(self) -> socket.socket: 940s """Establish a socket connection and set nodelay settings on it. 940s 940s :return: New socket connection. 940s """ 940s try: 940s > sock = connection.create_connection( 940s (self._dns_host, self.port), 940s self.timeout, 940s source_address=self.source_address, 940s socket_options=self.socket_options, 940s ) 940s 940s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 940s raise err 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 940s source_address = None, socket_options = [(6, 1, 1)] 940s 940s def create_connection( 940s address: tuple[str, int], 940s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 940s source_address: tuple[str, int] | None = None, 940s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 940s ) -> socket.socket: 940s """Connect to *address* and return the socket object. 940s 940s Convenience function. Connect to *address* (a 2-tuple ``(host, 940s port)``) and return the socket object. Passing the optional 940s *timeout* parameter will set the timeout on the socket instance 940s before attempting to connect. If no *timeout* is supplied, the 940s global default timeout setting returned by :func:`socket.getdefaulttimeout` 940s is used. If *source_address* is set it must be a tuple of (host, port) 940s for the socket to bind as a source address before making the connection. 940s An host of '' or port 0 tells the OS to use the default. 940s """ 940s 940s host, port = address 940s if host.startswith("["): 940s host = host.strip("[]") 940s err = None 940s 940s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 940s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 940s # The original create_connection function always returns all records. 940s family = allowed_gai_family() 940s 940s try: 940s host.encode("idna") 940s except UnicodeError: 940s raise LocationParseError(f"'{host}', label empty or too long") from None 940s 940s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 940s af, socktype, proto, canonname, sa = res 940s sock = None 940s try: 940s sock = socket.socket(af, socktype, proto) 940s 940s # If provided, set socket level options before connecting. 940s _set_socket_options(sock, socket_options) 940s 940s if timeout is not _DEFAULT_TIMEOUT: 940s sock.settimeout(timeout) 940s if source_address: 940s sock.bind(source_address) 940s > sock.connect(sa) 940s E ConnectionRefusedError: [Errno 111] Connection refused 940s 940s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 940s 940s The above exception was the direct cause of the following exception: 940s 940s self = 940s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 940s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 940s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 940s redirect = False, assert_same_host = False 940s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 940s release_conn = False, chunked = False, body_pos = None, preload_content = False 940s decode_content = False, response_kw = {} 940s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 940s destination_scheme = None, conn = None, release_this_conn = True 940s http_tunnel_required = False, err = None, clean_exit = False 940s 940s def urlopen( # type: ignore[override] 940s self, 940s method: str, 940s url: str, 940s body: _TYPE_BODY | None = None, 940s headers: typing.Mapping[str, str] | None = None, 940s retries: Retry | bool | int | None = None, 940s redirect: bool = True, 940s assert_same_host: bool = True, 940s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 940s pool_timeout: int | None = None, 940s release_conn: bool | None = None, 940s chunked: bool = False, 940s body_pos: _TYPE_BODY_POSITION | None = None, 940s preload_content: bool = True, 940s decode_content: bool = True, 940s **response_kw: typing.Any, 940s ) -> BaseHTTPResponse: 940s """ 940s Get a connection from the pool and perform an HTTP request. This is the 940s lowest level call for making a request, so you'll need to specify all 940s the raw details. 940s 940s .. note:: 940s 940s More commonly, it's appropriate to use a convenience method 940s such as :meth:`request`. 940s 940s .. note:: 940s 940s `release_conn` will only behave as expected if 940s `preload_content=False` because we want to make 940s `preload_content=False` the default behaviour someday soon without 940s breaking backwards compatibility. 940s 940s :param method: 940s HTTP request method (such as GET, POST, PUT, etc.) 940s 940s :param url: 940s The URL to perform the request on. 940s 940s :param body: 940s Data to send in the request body, either :class:`str`, :class:`bytes`, 940s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 940s 940s :param headers: 940s Dictionary of custom headers to send, such as User-Agent, 940s If-None-Match, etc. If None, pool headers are used. If provided, 940s these headers completely replace any pool-specific headers. 940s 940s :param retries: 940s Configure the number of retries to allow before raising a 940s :class:`~urllib3.exceptions.MaxRetryError` exception. 940s 940s Pass ``None`` to retry until you receive a response. Pass a 940s :class:`~urllib3.util.retry.Retry` object for fine-grained control 940s over different types of retries. 940s Pass an integer number to retry connection errors that many times, 940s but no other types of errors. Pass zero to never retry. 940s 940s If ``False``, then retries are disabled and any exception is raised 940s immediately. Also, instead of raising a MaxRetryError on redirects, 940s the redirect response will be returned. 940s 940s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 940s 940s :param redirect: 940s If True, automatically handle redirects (status codes 301, 302, 940s 303, 307, 308). Each redirect counts as a retry. Disabling retries 940s will disable redirect, too. 940s 940s :param assert_same_host: 940s If ``True``, will make sure that the host of the pool requests is 940s consistent else will raise HostChangedError. When ``False``, you can 940s use the pool on an HTTP proxy and request foreign hosts. 940s 940s :param timeout: 940s If specified, overrides the default timeout for this one 940s request. It may be a float (in seconds) or an instance of 940s :class:`urllib3.util.Timeout`. 940s 940s :param pool_timeout: 940s If set and the pool is set to block=True, then this method will 940s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 940s connection is available within the time period. 940s 940s :param bool preload_content: 940s If True, the response's body will be preloaded into memory. 940s 940s :param bool decode_content: 940s If True, will attempt to decode the body based on the 940s 'content-encoding' header. 940s 940s :param release_conn: 940s If False, then the urlopen call will not release the connection 940s back into the pool once a response is received (but will release if 940s you read the entire contents of the response such as when 940s `preload_content=True`). This is useful if you're not preloading 940s the response's content immediately. You will need to call 940s ``r.release_conn()`` on the response ``r`` to return the connection 940s back into the pool. If None, it takes the value of ``preload_content`` 940s which defaults to ``True``. 940s 940s :param bool chunked: 940s If True, urllib3 will send the body using chunked transfer 940s encoding. Otherwise, urllib3 will send the body using the standard 940s content-length form. Defaults to False. 940s 940s :param int body_pos: 940s Position to seek to in file-like body in the event of a retry or 940s redirect. Typically this won't need to be set because urllib3 will 940s auto-populate the value when needed. 940s """ 940s parsed_url = parse_url(url) 940s destination_scheme = parsed_url.scheme 940s 940s if headers is None: 940s headers = self.headers 940s 940s if not isinstance(retries, Retry): 940s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 940s 940s if release_conn is None: 940s release_conn = preload_content 940s 940s # Check host 940s if assert_same_host and not self.is_same_host(url): 940s raise HostChangedError(self, url, retries) 940s 940s # Ensure that the URL we're connecting to is properly encoded 940s if url.startswith("/"): 940s url = to_str(_encode_target(url)) 940s else: 940s url = to_str(parsed_url.url) 940s 940s conn = None 940s 940s # Track whether `conn` needs to be released before 940s # returning/raising/recursing. Update this variable if necessary, and 940s # leave `release_conn` constant throughout the function. That way, if 940s # the function recurses, the original value of `release_conn` will be 940s # passed down into the recursive call, and its value will be respected. 940s # 940s # See issue #651 [1] for details. 940s # 940s # [1] 940s release_this_conn = release_conn 940s 940s http_tunnel_required = connection_requires_http_tunnel( 940s self.proxy, self.proxy_config, destination_scheme 940s ) 940s 940s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 940s # have to copy the headers dict so we can safely change it without those 940s # changes being reflected in anyone else's copy. 940s if not http_tunnel_required: 940s headers = headers.copy() # type: ignore[attr-defined] 940s headers.update(self.proxy_headers) # type: ignore[union-attr] 940s 940s # Must keep the exception bound to a separate variable or else Python 3 940s # complains about UnboundLocalError. 940s err = None 940s 940s # Keep track of whether we cleanly exited the except block. This 940s # ensures we do proper cleanup in finally. 940s clean_exit = False 940s 940s # Rewind body position, if needed. Record current position 940s # for future rewinds in the event of a redirect/retry. 940s body_pos = set_file_position(body, body_pos) 940s 940s try: 940s # Request a connection from the queue. 940s timeout_obj = self._get_timeout(timeout) 940s conn = self._get_conn(timeout=pool_timeout) 940s 940s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 940s 940s # Is this a closed/new connection that requires CONNECT tunnelling? 940s if self.proxy is not None and http_tunnel_required and conn.is_closed: 940s try: 940s self._prepare_proxy(conn) 940s except (BaseSSLError, OSError, SocketTimeout) as e: 940s self._raise_timeout( 940s err=e, url=self.proxy.url, timeout_value=conn.timeout 940s ) 940s raise 940s 940s # If we're going to release the connection in ``finally:``, then 940s # the response doesn't need to know about the connection. Otherwise 940s # it will also try to release it and we'll have a double-release 940s # mess. 940s response_conn = conn if not release_conn else None 940s 940s # Make the request on the HTTPConnection object 940s > response = self._make_request( 940s conn, 940s method, 940s url, 940s timeout=timeout_obj, 940s body=body, 940s headers=headers, 940s chunked=chunked, 940s retries=retries, 940s response_conn=response_conn, 940s preload_content=preload_content, 940s decode_content=decode_content, 940s **response_kw, 940s ) 940s 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 940s raise new_e 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 940s self._validate_conn(conn) 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 940s conn.connect() 940s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 940s self.sock = sock = self._new_conn() 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s self = 940s 940s def _new_conn(self) -> socket.socket: 940s """Establish a socket connection and set nodelay settings on it. 940s 940s :return: New socket connection. 940s """ 940s try: 940s sock = connection.create_connection( 940s (self._dns_host, self.port), 940s self.timeout, 940s source_address=self.source_address, 940s socket_options=self.socket_options, 940s ) 940s except socket.gaierror as e: 940s raise NameResolutionError(self.host, self, e) from e 940s except SocketTimeout as e: 940s raise ConnectTimeoutError( 940s self, 940s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 940s ) from e 940s 940s except OSError as e: 940s > raise NewConnectionError( 940s self, f"Failed to establish a new connection: {e}" 940s ) from e 940s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 940s 940s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 940s 940s The above exception was the direct cause of the following exception: 940s 940s self = 940s request = , stream = False 940s timeout = Timeout(connect=None, read=None, total=None), verify = True 940s cert = None, proxies = OrderedDict() 940s 940s def send( 940s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 940s ): 940s """Sends PreparedRequest object. Returns Response object. 940s 940s :param request: The :class:`PreparedRequest ` being sent. 940s :param stream: (optional) Whether to stream the request content. 940s :param timeout: (optional) How long to wait for the server to send 940s data before giving up, as a float, or a :ref:`(connect timeout, 940s read timeout) ` tuple. 940s :type timeout: float or tuple or urllib3 Timeout object 940s :param verify: (optional) Either a boolean, in which case it controls whether 940s we verify the server's TLS certificate, or a string, in which case it 940s must be a path to a CA bundle to use 940s :param cert: (optional) Any user-provided SSL certificate to be trusted. 940s :param proxies: (optional) The proxies dictionary to apply to the request. 940s :rtype: requests.Response 940s """ 940s 940s try: 940s conn = self.get_connection_with_tls_context( 940s request, verify, proxies=proxies, cert=cert 940s ) 940s except LocationValueError as e: 940s raise InvalidURL(e, request=request) 940s 940s self.cert_verify(conn, request.url, verify, cert) 940s url = self.request_url(request, proxies) 940s self.add_headers( 940s request, 940s stream=stream, 940s timeout=timeout, 940s verify=verify, 940s cert=cert, 940s proxies=proxies, 940s ) 940s 940s chunked = not (request.body is None or "Content-Length" in request.headers) 940s 940s if isinstance(timeout, tuple): 940s try: 940s connect, read = timeout 940s timeout = TimeoutSauce(connect=connect, read=read) 940s except ValueError: 940s raise ValueError( 940s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 940s f"or a single float to set both timeouts to the same value." 940s ) 940s elif isinstance(timeout, TimeoutSauce): 940s pass 940s else: 940s timeout = TimeoutSauce(connect=timeout, read=timeout) 940s 940s try: 940s > resp = conn.urlopen( 940s method=request.method, 940s url=url, 940s body=request.body, 940s headers=request.headers, 940s redirect=False, 940s assert_same_host=False, 940s preload_content=False, 940s decode_content=False, 940s retries=self.max_retries, 940s timeout=timeout, 940s chunked=chunked, 940s ) 940s 940s /usr/lib/python3/dist-packages/requests/adapters.py:667: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 940s retries = retries.increment( 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 940s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 940s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 940s _pool = 940s _stacktrace = 940s 940s def increment( 940s self, 940s method: str | None = None, 940s url: str | None = None, 940s response: BaseHTTPResponse | None = None, 940s error: Exception | None = None, 940s _pool: ConnectionPool | None = None, 940s _stacktrace: TracebackType | None = None, 940s ) -> Retry: 940s """Return a new Retry object with incremented retry counters. 940s 940s :param response: A response object, or None, if the server did not 940s return a response. 940s :type response: :class:`~urllib3.response.BaseHTTPResponse` 940s :param Exception error: An error encountered during the request, or 940s None if the response was received successfully. 940s 940s :return: A new ``Retry`` object. 940s """ 940s if self.total is False and error: 940s # Disabled, indicate to re-raise the error. 940s raise reraise(type(error), error, _stacktrace) 940s 940s total = self.total 940s if total is not None: 940s total -= 1 940s 940s connect = self.connect 940s read = self.read 940s redirect = self.redirect 940s status_count = self.status 940s other = self.other 940s cause = "unknown" 940s status = None 940s redirect_location = None 940s 940s if error and self._is_connection_error(error): 940s # Connect retry? 940s if connect is False: 940s raise reraise(type(error), error, _stacktrace) 940s elif connect is not None: 940s connect -= 1 940s 940s elif error and self._is_read_error(error): 940s # Read retry? 940s if read is False or method is None or not self._is_method_retryable(method): 940s raise reraise(type(error), error, _stacktrace) 940s elif read is not None: 940s read -= 1 940s 940s elif error: 940s # Other retry? 940s if other is not None: 940s other -= 1 940s 940s elif response and response.get_redirect_location(): 940s # Redirect retry? 940s if redirect is not None: 940s redirect -= 1 940s cause = "too many redirects" 940s response_redirect_location = response.get_redirect_location() 940s if response_redirect_location: 940s redirect_location = response_redirect_location 940s status = response.status 940s 940s else: 940s # Incrementing because of a server error like a 500 in 940s # status_forcelist and the given method is in the allowed_methods 940s cause = ResponseError.GENERIC_ERROR 940s if response and response.status: 940s if status_count is not None: 940s status_count -= 1 940s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 940s status = response.status 940s 940s history = self.history + ( 940s RequestHistory(method, url, error, status, redirect_location), 940s ) 940s 940s new_retry = self.new( 940s total=total, 940s connect=connect, 940s read=read, 940s redirect=redirect, 940s status=status_count, 940s other=other, 940s history=history, 940s ) 940s 940s if new_retry.is_exhausted(): 940s reason = error or ResponseError(cause) 940s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 940s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 940s 940s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 940s 940s During handling of the above exception, another exception occurred: 940s 940s def test_simple(): 940s > enc = tiktoken.get_encoding("gpt2") 940s 940s tests/test_encoding.py:15: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 940s enc = Encoding(**constructor()) 940s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 940s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 940s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 940s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 940s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 940s contents = read_file(blobpath) 940s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 940s resp = requests.get(blobpath) 940s /usr/lib/python3/dist-packages/requests/api.py:73: in get 940s return request("get", url, params=params, **kwargs) 940s /usr/lib/python3/dist-packages/requests/api.py:59: in request 940s return session.request(method=method, url=url, **kwargs) 940s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 940s resp = self.send(prep, **send_kwargs) 940s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 940s r = adapter.send(request, **kwargs) 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s self = 940s request = , stream = False 940s timeout = Timeout(connect=None, read=None, total=None), verify = True 940s cert = None, proxies = OrderedDict() 940s 940s def send( 940s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 940s ): 940s """Sends PreparedRequest object. Returns Response object. 940s 940s :param request: The :class:`PreparedRequest ` being sent. 940s :param stream: (optional) Whether to stream the request content. 940s :param timeout: (optional) How long to wait for the server to send 940s data before giving up, as a float, or a :ref:`(connect timeout, 940s read timeout) ` tuple. 940s :type timeout: float or tuple or urllib3 Timeout object 940s :param verify: (optional) Either a boolean, in which case it controls whether 940s we verify the server's TLS certificate, or a string, in which case it 940s must be a path to a CA bundle to use 940s :param cert: (optional) Any user-provided SSL certificate to be trusted. 940s :param proxies: (optional) The proxies dictionary to apply to the request. 940s :rtype: requests.Response 940s """ 940s 940s try: 940s conn = self.get_connection_with_tls_context( 940s request, verify, proxies=proxies, cert=cert 940s ) 940s except LocationValueError as e: 940s raise InvalidURL(e, request=request) 940s 940s self.cert_verify(conn, request.url, verify, cert) 940s url = self.request_url(request, proxies) 940s self.add_headers( 940s request, 940s stream=stream, 940s timeout=timeout, 940s verify=verify, 940s cert=cert, 940s proxies=proxies, 940s ) 940s 940s chunked = not (request.body is None or "Content-Length" in request.headers) 940s 940s if isinstance(timeout, tuple): 940s try: 940s connect, read = timeout 940s timeout = TimeoutSauce(connect=connect, read=read) 940s except ValueError: 940s raise ValueError( 940s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 940s f"or a single float to set both timeouts to the same value." 940s ) 940s elif isinstance(timeout, TimeoutSauce): 940s pass 940s else: 940s timeout = TimeoutSauce(connect=timeout, read=timeout) 940s 940s try: 940s resp = conn.urlopen( 940s method=request.method, 940s url=url, 940s body=request.body, 940s headers=request.headers, 940s redirect=False, 940s assert_same_host=False, 940s preload_content=False, 940s decode_content=False, 940s retries=self.max_retries, 940s timeout=timeout, 940s chunked=chunked, 940s ) 940s 940s except (ProtocolError, OSError) as err: 940s raise ConnectionError(err, request=request) 940s 940s except MaxRetryError as e: 940s if isinstance(e.reason, ConnectTimeoutError): 940s # TODO: Remove this in 3.0.0: see #2811 940s if not isinstance(e.reason, NewConnectionError): 940s raise ConnectTimeout(e, request=request) 940s 940s if isinstance(e.reason, ResponseError): 940s raise RetryError(e, request=request) 940s 940s if isinstance(e.reason, _ProxyError): 940s raise ProxyError(e, request=request) 940s 940s if isinstance(e.reason, _SSLError): 940s # This branch is for urllib3 v1.22 and later. 940s raise SSLError(e, request=request) 940s 940s > raise ConnectionError(e, request=request) 940s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 940s 940s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 940s _____________________________ test_simple_repeated _____________________________ 940s 940s self = 940s 940s def _new_conn(self) -> socket.socket: 940s """Establish a socket connection and set nodelay settings on it. 940s 940s :return: New socket connection. 940s """ 940s try: 940s > sock = connection.create_connection( 940s (self._dns_host, self.port), 940s self.timeout, 940s source_address=self.source_address, 940s socket_options=self.socket_options, 940s ) 940s 940s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 940s raise err 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 940s source_address = None, socket_options = [(6, 1, 1)] 940s 940s def create_connection( 940s address: tuple[str, int], 940s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 940s source_address: tuple[str, int] | None = None, 940s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 940s ) -> socket.socket: 940s """Connect to *address* and return the socket object. 940s 940s Convenience function. Connect to *address* (a 2-tuple ``(host, 940s port)``) and return the socket object. Passing the optional 940s *timeout* parameter will set the timeout on the socket instance 940s before attempting to connect. If no *timeout* is supplied, the 940s global default timeout setting returned by :func:`socket.getdefaulttimeout` 940s is used. If *source_address* is set it must be a tuple of (host, port) 940s for the socket to bind as a source address before making the connection. 940s An host of '' or port 0 tells the OS to use the default. 940s """ 940s 940s host, port = address 940s if host.startswith("["): 940s host = host.strip("[]") 940s err = None 940s 940s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 940s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 940s # The original create_connection function always returns all records. 940s family = allowed_gai_family() 940s 940s try: 940s host.encode("idna") 940s except UnicodeError: 940s raise LocationParseError(f"'{host}', label empty or too long") from None 940s 940s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 940s af, socktype, proto, canonname, sa = res 940s sock = None 940s try: 940s sock = socket.socket(af, socktype, proto) 940s 940s # If provided, set socket level options before connecting. 940s _set_socket_options(sock, socket_options) 940s 940s if timeout is not _DEFAULT_TIMEOUT: 940s sock.settimeout(timeout) 940s if source_address: 940s sock.bind(source_address) 940s > sock.connect(sa) 940s E ConnectionRefusedError: [Errno 111] Connection refused 940s 940s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 940s 940s The above exception was the direct cause of the following exception: 940s 940s self = 940s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 940s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 940s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 940s redirect = False, assert_same_host = False 940s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 940s release_conn = False, chunked = False, body_pos = None, preload_content = False 940s decode_content = False, response_kw = {} 940s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 940s destination_scheme = None, conn = None, release_this_conn = True 940s http_tunnel_required = False, err = None, clean_exit = False 940s 940s def urlopen( # type: ignore[override] 940s self, 940s method: str, 940s url: str, 940s body: _TYPE_BODY | None = None, 940s headers: typing.Mapping[str, str] | None = None, 940s retries: Retry | bool | int | None = None, 940s redirect: bool = True, 940s assert_same_host: bool = True, 940s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 940s pool_timeout: int | None = None, 940s release_conn: bool | None = None, 940s chunked: bool = False, 940s body_pos: _TYPE_BODY_POSITION | None = None, 940s preload_content: bool = True, 940s decode_content: bool = True, 940s **response_kw: typing.Any, 940s ) -> BaseHTTPResponse: 940s """ 940s Get a connection from the pool and perform an HTTP request. This is the 940s lowest level call for making a request, so you'll need to specify all 940s the raw details. 940s 940s .. note:: 940s 940s More commonly, it's appropriate to use a convenience method 940s such as :meth:`request`. 940s 940s .. note:: 940s 940s `release_conn` will only behave as expected if 940s `preload_content=False` because we want to make 940s `preload_content=False` the default behaviour someday soon without 940s breaking backwards compatibility. 940s 940s :param method: 940s HTTP request method (such as GET, POST, PUT, etc.) 940s 940s :param url: 940s The URL to perform the request on. 940s 940s :param body: 940s Data to send in the request body, either :class:`str`, :class:`bytes`, 940s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 940s 940s :param headers: 940s Dictionary of custom headers to send, such as User-Agent, 940s If-None-Match, etc. If None, pool headers are used. If provided, 940s these headers completely replace any pool-specific headers. 940s 940s :param retries: 940s Configure the number of retries to allow before raising a 940s :class:`~urllib3.exceptions.MaxRetryError` exception. 940s 940s Pass ``None`` to retry until you receive a response. Pass a 940s :class:`~urllib3.util.retry.Retry` object for fine-grained control 940s over different types of retries. 940s Pass an integer number to retry connection errors that many times, 940s but no other types of errors. Pass zero to never retry. 940s 940s If ``False``, then retries are disabled and any exception is raised 940s immediately. Also, instead of raising a MaxRetryError on redirects, 940s the redirect response will be returned. 940s 940s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 940s 940s :param redirect: 940s If True, automatically handle redirects (status codes 301, 302, 940s 303, 307, 308). Each redirect counts as a retry. Disabling retries 940s will disable redirect, too. 940s 940s :param assert_same_host: 940s If ``True``, will make sure that the host of the pool requests is 940s consistent else will raise HostChangedError. When ``False``, you can 940s use the pool on an HTTP proxy and request foreign hosts. 940s 940s :param timeout: 940s If specified, overrides the default timeout for this one 940s request. It may be a float (in seconds) or an instance of 940s :class:`urllib3.util.Timeout`. 940s 940s :param pool_timeout: 940s If set and the pool is set to block=True, then this method will 940s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 940s connection is available within the time period. 940s 940s :param bool preload_content: 940s If True, the response's body will be preloaded into memory. 940s 940s :param bool decode_content: 940s If True, will attempt to decode the body based on the 940s 'content-encoding' header. 940s 940s :param release_conn: 940s If False, then the urlopen call will not release the connection 940s back into the pool once a response is received (but will release if 940s you read the entire contents of the response such as when 940s `preload_content=True`). This is useful if you're not preloading 940s the response's content immediately. You will need to call 940s ``r.release_conn()`` on the response ``r`` to return the connection 940s back into the pool. If None, it takes the value of ``preload_content`` 940s which defaults to ``True``. 940s 940s :param bool chunked: 940s If True, urllib3 will send the body using chunked transfer 940s encoding. Otherwise, urllib3 will send the body using the standard 940s content-length form. Defaults to False. 940s 940s :param int body_pos: 940s Position to seek to in file-like body in the event of a retry or 940s redirect. Typically this won't need to be set because urllib3 will 940s auto-populate the value when needed. 940s """ 940s parsed_url = parse_url(url) 940s destination_scheme = parsed_url.scheme 940s 940s if headers is None: 940s headers = self.headers 940s 940s if not isinstance(retries, Retry): 940s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 940s 940s if release_conn is None: 940s release_conn = preload_content 940s 940s # Check host 940s if assert_same_host and not self.is_same_host(url): 940s raise HostChangedError(self, url, retries) 940s 940s # Ensure that the URL we're connecting to is properly encoded 940s if url.startswith("/"): 940s url = to_str(_encode_target(url)) 940s else: 940s url = to_str(parsed_url.url) 940s 940s conn = None 940s 940s # Track whether `conn` needs to be released before 940s # returning/raising/recursing. Update this variable if necessary, and 940s # leave `release_conn` constant throughout the function. That way, if 940s # the function recurses, the original value of `release_conn` will be 940s # passed down into the recursive call, and its value will be respected. 940s # 940s # See issue #651 [1] for details. 940s # 940s # [1] 940s release_this_conn = release_conn 940s 940s http_tunnel_required = connection_requires_http_tunnel( 940s self.proxy, self.proxy_config, destination_scheme 940s ) 940s 940s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 940s # have to copy the headers dict so we can safely change it without those 940s # changes being reflected in anyone else's copy. 940s if not http_tunnel_required: 940s headers = headers.copy() # type: ignore[attr-defined] 940s headers.update(self.proxy_headers) # type: ignore[union-attr] 940s 940s # Must keep the exception bound to a separate variable or else Python 3 940s # complains about UnboundLocalError. 940s err = None 940s 940s # Keep track of whether we cleanly exited the except block. This 940s # ensures we do proper cleanup in finally. 940s clean_exit = False 940s 940s # Rewind body position, if needed. Record current position 940s # for future rewinds in the event of a redirect/retry. 940s body_pos = set_file_position(body, body_pos) 940s 940s try: 940s # Request a connection from the queue. 940s timeout_obj = self._get_timeout(timeout) 940s conn = self._get_conn(timeout=pool_timeout) 940s 940s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 940s 940s # Is this a closed/new connection that requires CONNECT tunnelling? 940s if self.proxy is not None and http_tunnel_required and conn.is_closed: 940s try: 940s self._prepare_proxy(conn) 940s except (BaseSSLError, OSError, SocketTimeout) as e: 940s self._raise_timeout( 940s err=e, url=self.proxy.url, timeout_value=conn.timeout 940s ) 940s raise 940s 940s # If we're going to release the connection in ``finally:``, then 940s # the response doesn't need to know about the connection. Otherwise 940s # it will also try to release it and we'll have a double-release 940s # mess. 940s response_conn = conn if not release_conn else None 940s 940s # Make the request on the HTTPConnection object 940s > response = self._make_request( 940s conn, 940s method, 940s url, 940s timeout=timeout_obj, 940s body=body, 940s headers=headers, 940s chunked=chunked, 940s retries=retries, 940s response_conn=response_conn, 940s preload_content=preload_content, 940s decode_content=decode_content, 940s **response_kw, 940s ) 940s 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 940s raise new_e 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 940s self._validate_conn(conn) 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 940s conn.connect() 940s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 940s self.sock = sock = self._new_conn() 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s self = 940s 940s def _new_conn(self) -> socket.socket: 940s """Establish a socket connection and set nodelay settings on it. 940s 940s :return: New socket connection. 940s """ 940s try: 940s sock = connection.create_connection( 940s (self._dns_host, self.port), 940s self.timeout, 940s source_address=self.source_address, 940s socket_options=self.socket_options, 940s ) 940s except socket.gaierror as e: 940s raise NameResolutionError(self.host, self, e) from e 940s except SocketTimeout as e: 940s raise ConnectTimeoutError( 940s self, 940s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 940s ) from e 940s 940s except OSError as e: 940s > raise NewConnectionError( 940s self, f"Failed to establish a new connection: {e}" 940s ) from e 940s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 940s 940s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 940s 940s The above exception was the direct cause of the following exception: 940s 940s self = 940s request = , stream = False 940s timeout = Timeout(connect=None, read=None, total=None), verify = True 940s cert = None, proxies = OrderedDict() 940s 940s def send( 940s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 940s ): 940s """Sends PreparedRequest object. Returns Response object. 940s 940s :param request: The :class:`PreparedRequest ` being sent. 940s :param stream: (optional) Whether to stream the request content. 940s :param timeout: (optional) How long to wait for the server to send 940s data before giving up, as a float, or a :ref:`(connect timeout, 940s read timeout) ` tuple. 940s :type timeout: float or tuple or urllib3 Timeout object 940s :param verify: (optional) Either a boolean, in which case it controls whether 940s we verify the server's TLS certificate, or a string, in which case it 940s must be a path to a CA bundle to use 940s :param cert: (optional) Any user-provided SSL certificate to be trusted. 940s :param proxies: (optional) The proxies dictionary to apply to the request. 940s :rtype: requests.Response 940s """ 940s 940s try: 940s conn = self.get_connection_with_tls_context( 940s request, verify, proxies=proxies, cert=cert 940s ) 940s except LocationValueError as e: 940s raise InvalidURL(e, request=request) 940s 940s self.cert_verify(conn, request.url, verify, cert) 940s url = self.request_url(request, proxies) 940s self.add_headers( 940s request, 940s stream=stream, 940s timeout=timeout, 940s verify=verify, 940s cert=cert, 940s proxies=proxies, 940s ) 940s 940s chunked = not (request.body is None or "Content-Length" in request.headers) 940s 940s if isinstance(timeout, tuple): 940s try: 940s connect, read = timeout 940s timeout = TimeoutSauce(connect=connect, read=read) 940s except ValueError: 940s raise ValueError( 940s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 940s f"or a single float to set both timeouts to the same value." 940s ) 940s elif isinstance(timeout, TimeoutSauce): 940s pass 940s else: 940s timeout = TimeoutSauce(connect=timeout, read=timeout) 940s 940s try: 940s > resp = conn.urlopen( 940s method=request.method, 940s url=url, 940s body=request.body, 940s headers=request.headers, 940s redirect=False, 940s assert_same_host=False, 940s preload_content=False, 940s decode_content=False, 940s retries=self.max_retries, 940s timeout=timeout, 940s chunked=chunked, 940s ) 940s 940s /usr/lib/python3/dist-packages/requests/adapters.py:667: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 940s retries = retries.increment( 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 940s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 940s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 940s _pool = 940s _stacktrace = 940s 940s def increment( 940s self, 940s method: str | None = None, 940s url: str | None = None, 940s response: BaseHTTPResponse | None = None, 940s error: Exception | None = None, 940s _pool: ConnectionPool | None = None, 940s _stacktrace: TracebackType | None = None, 940s ) -> Retry: 940s """Return a new Retry object with incremented retry counters. 940s 940s :param response: A response object, or None, if the server did not 940s return a response. 940s :type response: :class:`~urllib3.response.BaseHTTPResponse` 940s :param Exception error: An error encountered during the request, or 940s None if the response was received successfully. 940s 940s :return: A new ``Retry`` object. 940s """ 940s if self.total is False and error: 940s # Disabled, indicate to re-raise the error. 940s raise reraise(type(error), error, _stacktrace) 940s 940s total = self.total 940s if total is not None: 940s total -= 1 940s 940s connect = self.connect 940s read = self.read 940s redirect = self.redirect 940s status_count = self.status 940s other = self.other 940s cause = "unknown" 940s status = None 940s redirect_location = None 940s 940s if error and self._is_connection_error(error): 940s # Connect retry? 940s if connect is False: 940s raise reraise(type(error), error, _stacktrace) 940s elif connect is not None: 940s connect -= 1 940s 940s elif error and self._is_read_error(error): 940s # Read retry? 940s if read is False or method is None or not self._is_method_retryable(method): 940s raise reraise(type(error), error, _stacktrace) 940s elif read is not None: 940s read -= 1 940s 940s elif error: 940s # Other retry? 940s if other is not None: 940s other -= 1 940s 940s elif response and response.get_redirect_location(): 940s # Redirect retry? 940s if redirect is not None: 940s redirect -= 1 940s cause = "too many redirects" 940s response_redirect_location = response.get_redirect_location() 940s if response_redirect_location: 940s redirect_location = response_redirect_location 940s status = response.status 940s 940s else: 940s # Incrementing because of a server error like a 500 in 940s # status_forcelist and the given method is in the allowed_methods 940s cause = ResponseError.GENERIC_ERROR 940s if response and response.status: 940s if status_count is not None: 940s status_count -= 1 940s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 940s status = response.status 940s 940s history = self.history + ( 940s RequestHistory(method, url, error, status, redirect_location), 940s ) 940s 940s new_retry = self.new( 940s total=total, 940s connect=connect, 940s read=read, 940s redirect=redirect, 940s status=status_count, 940s other=other, 940s history=history, 940s ) 940s 940s if new_retry.is_exhausted(): 940s reason = error or ResponseError(cause) 940s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 940s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 940s 940s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 940s 940s During handling of the above exception, another exception occurred: 940s 940s def test_simple_repeated(): 940s > enc = tiktoken.get_encoding("gpt2") 940s 940s tests/test_encoding.py:32: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 940s enc = Encoding(**constructor()) 940s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 940s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 940s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 940s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 940s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 940s contents = read_file(blobpath) 940s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 940s resp = requests.get(blobpath) 940s /usr/lib/python3/dist-packages/requests/api.py:73: in get 940s return request("get", url, params=params, **kwargs) 940s /usr/lib/python3/dist-packages/requests/api.py:59: in request 940s return session.request(method=method, url=url, **kwargs) 940s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 940s resp = self.send(prep, **send_kwargs) 940s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 940s r = adapter.send(request, **kwargs) 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s self = 940s request = , stream = False 940s timeout = Timeout(connect=None, read=None, total=None), verify = True 940s cert = None, proxies = OrderedDict() 940s 940s def send( 940s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 940s ): 940s """Sends PreparedRequest object. Returns Response object. 940s 940s :param request: The :class:`PreparedRequest ` being sent. 940s :param stream: (optional) Whether to stream the request content. 940s :param timeout: (optional) How long to wait for the server to send 940s data before giving up, as a float, or a :ref:`(connect timeout, 940s read timeout) ` tuple. 940s :type timeout: float or tuple or urllib3 Timeout object 940s :param verify: (optional) Either a boolean, in which case it controls whether 940s we verify the server's TLS certificate, or a string, in which case it 940s must be a path to a CA bundle to use 940s :param cert: (optional) Any user-provided SSL certificate to be trusted. 940s :param proxies: (optional) The proxies dictionary to apply to the request. 940s :rtype: requests.Response 940s """ 940s 940s try: 940s conn = self.get_connection_with_tls_context( 940s request, verify, proxies=proxies, cert=cert 940s ) 940s except LocationValueError as e: 940s raise InvalidURL(e, request=request) 940s 940s self.cert_verify(conn, request.url, verify, cert) 940s url = self.request_url(request, proxies) 940s self.add_headers( 940s request, 940s stream=stream, 940s timeout=timeout, 940s verify=verify, 940s cert=cert, 940s proxies=proxies, 940s ) 940s 940s chunked = not (request.body is None or "Content-Length" in request.headers) 940s 940s if isinstance(timeout, tuple): 940s try: 940s connect, read = timeout 940s timeout = TimeoutSauce(connect=connect, read=read) 940s except ValueError: 940s raise ValueError( 940s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 940s f"or a single float to set both timeouts to the same value." 940s ) 940s elif isinstance(timeout, TimeoutSauce): 940s pass 940s else: 940s timeout = TimeoutSauce(connect=timeout, read=timeout) 940s 940s try: 940s resp = conn.urlopen( 940s method=request.method, 940s url=url, 940s body=request.body, 940s headers=request.headers, 940s redirect=False, 940s assert_same_host=False, 940s preload_content=False, 940s decode_content=False, 940s retries=self.max_retries, 940s timeout=timeout, 940s chunked=chunked, 940s ) 940s 940s except (ProtocolError, OSError) as err: 940s raise ConnectionError(err, request=request) 940s 940s except MaxRetryError as e: 940s if isinstance(e.reason, ConnectTimeoutError): 940s # TODO: Remove this in 3.0.0: see #2811 940s if not isinstance(e.reason, NewConnectionError): 940s raise ConnectTimeout(e, request=request) 940s 940s if isinstance(e.reason, ResponseError): 940s raise RetryError(e, request=request) 940s 940s if isinstance(e.reason, _ProxyError): 940s raise ProxyError(e, request=request) 940s 940s if isinstance(e.reason, _SSLError): 940s # This branch is for urllib3 v1.22 and later. 940s raise SSLError(e, request=request) 940s 940s > raise ConnectionError(e, request=request) 940s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 940s 940s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 940s ______________________________ test_simple_regex _______________________________ 940s 940s self = 940s 940s def _new_conn(self) -> socket.socket: 940s """Establish a socket connection and set nodelay settings on it. 940s 940s :return: New socket connection. 940s """ 940s try: 940s > sock = connection.create_connection( 940s (self._dns_host, self.port), 940s self.timeout, 940s source_address=self.source_address, 940s socket_options=self.socket_options, 940s ) 940s 940s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 940s raise err 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 940s source_address = None, socket_options = [(6, 1, 1)] 940s 940s def create_connection( 940s address: tuple[str, int], 940s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 940s source_address: tuple[str, int] | None = None, 940s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 940s ) -> socket.socket: 940s """Connect to *address* and return the socket object. 940s 940s Convenience function. Connect to *address* (a 2-tuple ``(host, 940s port)``) and return the socket object. Passing the optional 940s *timeout* parameter will set the timeout on the socket instance 940s before attempting to connect. If no *timeout* is supplied, the 940s global default timeout setting returned by :func:`socket.getdefaulttimeout` 940s is used. If *source_address* is set it must be a tuple of (host, port) 940s for the socket to bind as a source address before making the connection. 940s An host of '' or port 0 tells the OS to use the default. 940s """ 940s 940s host, port = address 940s if host.startswith("["): 940s host = host.strip("[]") 940s err = None 940s 940s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 940s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 940s # The original create_connection function always returns all records. 940s family = allowed_gai_family() 940s 940s try: 940s host.encode("idna") 940s except UnicodeError: 940s raise LocationParseError(f"'{host}', label empty or too long") from None 940s 940s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 940s af, socktype, proto, canonname, sa = res 940s sock = None 940s try: 940s sock = socket.socket(af, socktype, proto) 940s 940s # If provided, set socket level options before connecting. 940s _set_socket_options(sock, socket_options) 940s 940s if timeout is not _DEFAULT_TIMEOUT: 940s sock.settimeout(timeout) 940s if source_address: 940s sock.bind(source_address) 940s > sock.connect(sa) 940s E ConnectionRefusedError: [Errno 111] Connection refused 940s 940s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 940s 940s The above exception was the direct cause of the following exception: 940s 940s self = 940s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 940s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 940s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 940s redirect = False, assert_same_host = False 940s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 940s release_conn = False, chunked = False, body_pos = None, preload_content = False 940s decode_content = False, response_kw = {} 940s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 940s destination_scheme = None, conn = None, release_this_conn = True 940s http_tunnel_required = False, err = None, clean_exit = False 940s 940s def urlopen( # type: ignore[override] 940s self, 940s method: str, 940s url: str, 940s body: _TYPE_BODY | None = None, 940s headers: typing.Mapping[str, str] | None = None, 940s retries: Retry | bool | int | None = None, 940s redirect: bool = True, 940s assert_same_host: bool = True, 940s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 940s pool_timeout: int | None = None, 940s release_conn: bool | None = None, 940s chunked: bool = False, 940s body_pos: _TYPE_BODY_POSITION | None = None, 940s preload_content: bool = True, 940s decode_content: bool = True, 940s **response_kw: typing.Any, 940s ) -> BaseHTTPResponse: 940s """ 940s Get a connection from the pool and perform an HTTP request. This is the 940s lowest level call for making a request, so you'll need to specify all 940s the raw details. 940s 940s .. note:: 940s 940s More commonly, it's appropriate to use a convenience method 940s such as :meth:`request`. 940s 940s .. note:: 940s 940s `release_conn` will only behave as expected if 940s `preload_content=False` because we want to make 940s `preload_content=False` the default behaviour someday soon without 940s breaking backwards compatibility. 940s 940s :param method: 940s HTTP request method (such as GET, POST, PUT, etc.) 940s 940s :param url: 940s The URL to perform the request on. 940s 940s :param body: 940s Data to send in the request body, either :class:`str`, :class:`bytes`, 940s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 940s 940s :param headers: 940s Dictionary of custom headers to send, such as User-Agent, 940s If-None-Match, etc. If None, pool headers are used. If provided, 940s these headers completely replace any pool-specific headers. 940s 940s :param retries: 940s Configure the number of retries to allow before raising a 940s :class:`~urllib3.exceptions.MaxRetryError` exception. 940s 940s Pass ``None`` to retry until you receive a response. Pass a 940s :class:`~urllib3.util.retry.Retry` object for fine-grained control 940s over different types of retries. 940s Pass an integer number to retry connection errors that many times, 940s but no other types of errors. Pass zero to never retry. 940s 940s If ``False``, then retries are disabled and any exception is raised 940s immediately. Also, instead of raising a MaxRetryError on redirects, 940s the redirect response will be returned. 940s 940s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 940s 940s :param redirect: 940s If True, automatically handle redirects (status codes 301, 302, 940s 303, 307, 308). Each redirect counts as a retry. Disabling retries 940s will disable redirect, too. 940s 940s :param assert_same_host: 940s If ``True``, will make sure that the host of the pool requests is 940s consistent else will raise HostChangedError. When ``False``, you can 940s use the pool on an HTTP proxy and request foreign hosts. 940s 940s :param timeout: 940s If specified, overrides the default timeout for this one 940s request. It may be a float (in seconds) or an instance of 940s :class:`urllib3.util.Timeout`. 940s 940s :param pool_timeout: 940s If set and the pool is set to block=True, then this method will 940s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 940s connection is available within the time period. 940s 940s :param bool preload_content: 940s If True, the response's body will be preloaded into memory. 940s 940s :param bool decode_content: 940s If True, will attempt to decode the body based on the 940s 'content-encoding' header. 940s 940s :param release_conn: 940s If False, then the urlopen call will not release the connection 940s back into the pool once a response is received (but will release if 940s you read the entire contents of the response such as when 940s `preload_content=True`). This is useful if you're not preloading 940s the response's content immediately. You will need to call 940s ``r.release_conn()`` on the response ``r`` to return the connection 940s back into the pool. If None, it takes the value of ``preload_content`` 940s which defaults to ``True``. 940s 940s :param bool chunked: 940s If True, urllib3 will send the body using chunked transfer 940s encoding. Otherwise, urllib3 will send the body using the standard 940s content-length form. Defaults to False. 940s 940s :param int body_pos: 940s Position to seek to in file-like body in the event of a retry or 940s redirect. Typically this won't need to be set because urllib3 will 940s auto-populate the value when needed. 940s """ 940s parsed_url = parse_url(url) 940s destination_scheme = parsed_url.scheme 940s 940s if headers is None: 940s headers = self.headers 940s 940s if not isinstance(retries, Retry): 940s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 940s 940s if release_conn is None: 940s release_conn = preload_content 940s 940s # Check host 940s if assert_same_host and not self.is_same_host(url): 940s raise HostChangedError(self, url, retries) 940s 940s # Ensure that the URL we're connecting to is properly encoded 940s if url.startswith("/"): 940s url = to_str(_encode_target(url)) 940s else: 940s url = to_str(parsed_url.url) 940s 940s conn = None 940s 940s # Track whether `conn` needs to be released before 940s # returning/raising/recursing. Update this variable if necessary, and 940s # leave `release_conn` constant throughout the function. That way, if 940s # the function recurses, the original value of `release_conn` will be 940s # passed down into the recursive call, and its value will be respected. 940s # 940s # See issue #651 [1] for details. 940s # 940s # [1] 940s release_this_conn = release_conn 940s 940s http_tunnel_required = connection_requires_http_tunnel( 940s self.proxy, self.proxy_config, destination_scheme 940s ) 940s 940s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 940s # have to copy the headers dict so we can safely change it without those 940s # changes being reflected in anyone else's copy. 940s if not http_tunnel_required: 940s headers = headers.copy() # type: ignore[attr-defined] 940s headers.update(self.proxy_headers) # type: ignore[union-attr] 940s 940s # Must keep the exception bound to a separate variable or else Python 3 940s # complains about UnboundLocalError. 940s err = None 940s 940s # Keep track of whether we cleanly exited the except block. This 940s # ensures we do proper cleanup in finally. 940s clean_exit = False 940s 940s # Rewind body position, if needed. Record current position 940s # for future rewinds in the event of a redirect/retry. 940s body_pos = set_file_position(body, body_pos) 940s 940s try: 940s # Request a connection from the queue. 940s timeout_obj = self._get_timeout(timeout) 940s conn = self._get_conn(timeout=pool_timeout) 940s 940s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 940s 940s # Is this a closed/new connection that requires CONNECT tunnelling? 940s if self.proxy is not None and http_tunnel_required and conn.is_closed: 940s try: 940s self._prepare_proxy(conn) 940s except (BaseSSLError, OSError, SocketTimeout) as e: 940s self._raise_timeout( 940s err=e, url=self.proxy.url, timeout_value=conn.timeout 940s ) 940s raise 940s 940s # If we're going to release the connection in ``finally:``, then 940s # the response doesn't need to know about the connection. Otherwise 940s # it will also try to release it and we'll have a double-release 940s # mess. 940s response_conn = conn if not release_conn else None 940s 940s # Make the request on the HTTPConnection object 940s > response = self._make_request( 940s conn, 940s method, 940s url, 940s timeout=timeout_obj, 940s body=body, 940s headers=headers, 940s chunked=chunked, 940s retries=retries, 940s response_conn=response_conn, 940s preload_content=preload_content, 940s decode_content=decode_content, 940s **response_kw, 940s ) 940s 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 940s raise new_e 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 940s self._validate_conn(conn) 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 940s conn.connect() 940s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 940s self.sock = sock = self._new_conn() 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s self = 940s 940s def _new_conn(self) -> socket.socket: 940s """Establish a socket connection and set nodelay settings on it. 940s 940s :return: New socket connection. 940s """ 940s try: 940s sock = connection.create_connection( 940s (self._dns_host, self.port), 940s self.timeout, 940s source_address=self.source_address, 940s socket_options=self.socket_options, 940s ) 940s except socket.gaierror as e: 940s raise NameResolutionError(self.host, self, e) from e 940s except SocketTimeout as e: 940s raise ConnectTimeoutError( 940s self, 940s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 940s ) from e 940s 940s except OSError as e: 940s > raise NewConnectionError( 940s self, f"Failed to establish a new connection: {e}" 940s ) from e 940s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 940s 940s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 940s 940s The above exception was the direct cause of the following exception: 940s 940s self = 940s request = , stream = False 940s timeout = Timeout(connect=None, read=None, total=None), verify = True 940s cert = None, proxies = OrderedDict() 940s 940s def send( 940s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 940s ): 940s """Sends PreparedRequest object. Returns Response object. 940s 940s :param request: The :class:`PreparedRequest ` being sent. 940s :param stream: (optional) Whether to stream the request content. 940s :param timeout: (optional) How long to wait for the server to send 940s data before giving up, as a float, or a :ref:`(connect timeout, 940s read timeout) ` tuple. 940s :type timeout: float or tuple or urllib3 Timeout object 940s :param verify: (optional) Either a boolean, in which case it controls whether 940s we verify the server's TLS certificate, or a string, in which case it 940s must be a path to a CA bundle to use 940s :param cert: (optional) Any user-provided SSL certificate to be trusted. 940s :param proxies: (optional) The proxies dictionary to apply to the request. 940s :rtype: requests.Response 940s """ 940s 940s try: 940s conn = self.get_connection_with_tls_context( 940s request, verify, proxies=proxies, cert=cert 940s ) 940s except LocationValueError as e: 940s raise InvalidURL(e, request=request) 940s 940s self.cert_verify(conn, request.url, verify, cert) 940s url = self.request_url(request, proxies) 940s self.add_headers( 940s request, 940s stream=stream, 940s timeout=timeout, 940s verify=verify, 940s cert=cert, 940s proxies=proxies, 940s ) 940s 940s chunked = not (request.body is None or "Content-Length" in request.headers) 940s 940s if isinstance(timeout, tuple): 940s try: 940s connect, read = timeout 940s timeout = TimeoutSauce(connect=connect, read=read) 940s except ValueError: 940s raise ValueError( 940s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 940s f"or a single float to set both timeouts to the same value." 940s ) 940s elif isinstance(timeout, TimeoutSauce): 940s pass 940s else: 940s timeout = TimeoutSauce(connect=timeout, read=timeout) 940s 940s try: 940s > resp = conn.urlopen( 940s method=request.method, 940s url=url, 940s body=request.body, 940s headers=request.headers, 940s redirect=False, 940s assert_same_host=False, 940s preload_content=False, 940s decode_content=False, 940s retries=self.max_retries, 940s timeout=timeout, 940s chunked=chunked, 940s ) 940s 940s /usr/lib/python3/dist-packages/requests/adapters.py:667: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 940s retries = retries.increment( 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 940s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 940s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 940s _pool = 940s _stacktrace = 940s 940s def increment( 940s self, 940s method: str | None = None, 940s url: str | None = None, 940s response: BaseHTTPResponse | None = None, 940s error: Exception | None = None, 940s _pool: ConnectionPool | None = None, 940s _stacktrace: TracebackType | None = None, 940s ) -> Retry: 940s """Return a new Retry object with incremented retry counters. 940s 940s :param response: A response object, or None, if the server did not 940s return a response. 940s :type response: :class:`~urllib3.response.BaseHTTPResponse` 940s :param Exception error: An error encountered during the request, or 940s None if the response was received successfully. 940s 940s :return: A new ``Retry`` object. 940s """ 940s if self.total is False and error: 940s # Disabled, indicate to re-raise the error. 940s raise reraise(type(error), error, _stacktrace) 940s 940s total = self.total 940s if total is not None: 940s total -= 1 940s 940s connect = self.connect 940s read = self.read 940s redirect = self.redirect 940s status_count = self.status 940s other = self.other 940s cause = "unknown" 940s status = None 940s redirect_location = None 940s 940s if error and self._is_connection_error(error): 940s # Connect retry? 940s if connect is False: 940s raise reraise(type(error), error, _stacktrace) 940s elif connect is not None: 940s connect -= 1 940s 940s elif error and self._is_read_error(error): 940s # Read retry? 940s if read is False or method is None or not self._is_method_retryable(method): 940s raise reraise(type(error), error, _stacktrace) 940s elif read is not None: 940s read -= 1 940s 940s elif error: 940s # Other retry? 940s if other is not None: 940s other -= 1 940s 940s elif response and response.get_redirect_location(): 940s # Redirect retry? 940s if redirect is not None: 940s redirect -= 1 940s cause = "too many redirects" 940s response_redirect_location = response.get_redirect_location() 940s if response_redirect_location: 940s redirect_location = response_redirect_location 940s status = response.status 940s 940s else: 940s # Incrementing because of a server error like a 500 in 940s # status_forcelist and the given method is in the allowed_methods 940s cause = ResponseError.GENERIC_ERROR 940s if response and response.status: 940s if status_count is not None: 940s status_count -= 1 940s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 940s status = response.status 940s 940s history = self.history + ( 940s RequestHistory(method, url, error, status, redirect_location), 940s ) 940s 940s new_retry = self.new( 940s total=total, 940s connect=connect, 940s read=read, 940s redirect=redirect, 940s status=status_count, 940s other=other, 940s history=history, 940s ) 940s 940s if new_retry.is_exhausted(): 940s reason = error or ResponseError(cause) 940s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 940s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 940s 940s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 940s 940s During handling of the above exception, another exception occurred: 940s 940s def test_simple_regex(): 940s > enc = tiktoken.get_encoding("cl100k_base") 940s 940s tests/test_encoding.py:53: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 940s enc = Encoding(**constructor()) 940s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 940s mergeable_ranks = load_tiktoken_bpe( 940s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 940s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 940s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 940s contents = read_file(blobpath) 940s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 940s resp = requests.get(blobpath) 940s /usr/lib/python3/dist-packages/requests/api.py:73: in get 940s return request("get", url, params=params, **kwargs) 940s /usr/lib/python3/dist-packages/requests/api.py:59: in request 940s return session.request(method=method, url=url, **kwargs) 940s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 940s resp = self.send(prep, **send_kwargs) 940s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 940s r = adapter.send(request, **kwargs) 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s self = 940s request = , stream = False 940s timeout = Timeout(connect=None, read=None, total=None), verify = True 940s cert = None, proxies = OrderedDict() 940s 940s def send( 940s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 940s ): 940s """Sends PreparedRequest object. Returns Response object. 940s 940s :param request: The :class:`PreparedRequest ` being sent. 940s :param stream: (optional) Whether to stream the request content. 940s :param timeout: (optional) How long to wait for the server to send 940s data before giving up, as a float, or a :ref:`(connect timeout, 940s read timeout) ` tuple. 940s :type timeout: float or tuple or urllib3 Timeout object 940s :param verify: (optional) Either a boolean, in which case it controls whether 940s we verify the server's TLS certificate, or a string, in which case it 940s must be a path to a CA bundle to use 940s :param cert: (optional) Any user-provided SSL certificate to be trusted. 940s :param proxies: (optional) The proxies dictionary to apply to the request. 940s :rtype: requests.Response 940s """ 940s 940s try: 940s conn = self.get_connection_with_tls_context( 940s request, verify, proxies=proxies, cert=cert 940s ) 940s except LocationValueError as e: 940s raise InvalidURL(e, request=request) 940s 940s self.cert_verify(conn, request.url, verify, cert) 940s url = self.request_url(request, proxies) 940s self.add_headers( 940s request, 940s stream=stream, 940s timeout=timeout, 940s verify=verify, 940s cert=cert, 940s proxies=proxies, 940s ) 940s 940s chunked = not (request.body is None or "Content-Length" in request.headers) 940s 940s if isinstance(timeout, tuple): 940s try: 940s connect, read = timeout 940s timeout = TimeoutSauce(connect=connect, read=read) 940s except ValueError: 940s raise ValueError( 940s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 940s f"or a single float to set both timeouts to the same value." 940s ) 940s elif isinstance(timeout, TimeoutSauce): 940s pass 940s else: 940s timeout = TimeoutSauce(connect=timeout, read=timeout) 940s 940s try: 940s resp = conn.urlopen( 940s method=request.method, 940s url=url, 940s body=request.body, 940s headers=request.headers, 940s redirect=False, 940s assert_same_host=False, 940s preload_content=False, 940s decode_content=False, 940s retries=self.max_retries, 940s timeout=timeout, 940s chunked=chunked, 940s ) 940s 940s except (ProtocolError, OSError) as err: 940s raise ConnectionError(err, request=request) 940s 940s except MaxRetryError as e: 940s if isinstance(e.reason, ConnectTimeoutError): 940s # TODO: Remove this in 3.0.0: see #2811 940s if not isinstance(e.reason, NewConnectionError): 940s raise ConnectTimeout(e, request=request) 940s 940s if isinstance(e.reason, ResponseError): 940s raise RetryError(e, request=request) 940s 940s if isinstance(e.reason, _ProxyError): 940s raise ProxyError(e, request=request) 940s 940s if isinstance(e.reason, _SSLError): 940s # This branch is for urllib3 v1.22 and later. 940s raise SSLError(e, request=request) 940s 940s > raise ConnectionError(e, request=request) 940s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 940s 940s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 940s ______________________________ test_basic_encode _______________________________ 940s 940s self = 940s 940s def _new_conn(self) -> socket.socket: 940s """Establish a socket connection and set nodelay settings on it. 940s 940s :return: New socket connection. 940s """ 940s try: 940s > sock = connection.create_connection( 940s (self._dns_host, self.port), 940s self.timeout, 940s source_address=self.source_address, 940s socket_options=self.socket_options, 940s ) 940s 940s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 940s raise err 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 940s source_address = None, socket_options = [(6, 1, 1)] 940s 940s def create_connection( 940s address: tuple[str, int], 940s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 940s source_address: tuple[str, int] | None = None, 940s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 940s ) -> socket.socket: 940s """Connect to *address* and return the socket object. 940s 940s Convenience function. Connect to *address* (a 2-tuple ``(host, 940s port)``) and return the socket object. Passing the optional 940s *timeout* parameter will set the timeout on the socket instance 940s before attempting to connect. If no *timeout* is supplied, the 940s global default timeout setting returned by :func:`socket.getdefaulttimeout` 940s is used. If *source_address* is set it must be a tuple of (host, port) 940s for the socket to bind as a source address before making the connection. 940s An host of '' or port 0 tells the OS to use the default. 940s """ 940s 940s host, port = address 940s if host.startswith("["): 940s host = host.strip("[]") 940s err = None 940s 940s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 940s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 940s # The original create_connection function always returns all records. 940s family = allowed_gai_family() 940s 940s try: 940s host.encode("idna") 940s except UnicodeError: 940s raise LocationParseError(f"'{host}', label empty or too long") from None 940s 940s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 940s af, socktype, proto, canonname, sa = res 940s sock = None 940s try: 940s sock = socket.socket(af, socktype, proto) 940s 940s # If provided, set socket level options before connecting. 940s _set_socket_options(sock, socket_options) 940s 940s if timeout is not _DEFAULT_TIMEOUT: 940s sock.settimeout(timeout) 940s if source_address: 940s sock.bind(source_address) 940s > sock.connect(sa) 940s E ConnectionRefusedError: [Errno 111] Connection refused 940s 940s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 940s 940s The above exception was the direct cause of the following exception: 940s 940s self = 940s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 940s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 940s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 940s redirect = False, assert_same_host = False 940s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 940s release_conn = False, chunked = False, body_pos = None, preload_content = False 940s decode_content = False, response_kw = {} 940s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 940s destination_scheme = None, conn = None, release_this_conn = True 940s http_tunnel_required = False, err = None, clean_exit = False 940s 940s def urlopen( # type: ignore[override] 940s self, 940s method: str, 940s url: str, 940s body: _TYPE_BODY | None = None, 940s headers: typing.Mapping[str, str] | None = None, 940s retries: Retry | bool | int | None = None, 940s redirect: bool = True, 940s assert_same_host: bool = True, 940s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 940s pool_timeout: int | None = None, 940s release_conn: bool | None = None, 940s chunked: bool = False, 940s body_pos: _TYPE_BODY_POSITION | None = None, 940s preload_content: bool = True, 940s decode_content: bool = True, 940s **response_kw: typing.Any, 940s ) -> BaseHTTPResponse: 940s """ 940s Get a connection from the pool and perform an HTTP request. This is the 940s lowest level call for making a request, so you'll need to specify all 940s the raw details. 940s 940s .. note:: 940s 940s More commonly, it's appropriate to use a convenience method 940s such as :meth:`request`. 940s 940s .. note:: 940s 940s `release_conn` will only behave as expected if 940s `preload_content=False` because we want to make 940s `preload_content=False` the default behaviour someday soon without 940s breaking backwards compatibility. 940s 940s :param method: 940s HTTP request method (such as GET, POST, PUT, etc.) 940s 940s :param url: 940s The URL to perform the request on. 940s 940s :param body: 940s Data to send in the request body, either :class:`str`, :class:`bytes`, 940s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 940s 940s :param headers: 940s Dictionary of custom headers to send, such as User-Agent, 940s If-None-Match, etc. If None, pool headers are used. If provided, 940s these headers completely replace any pool-specific headers. 940s 940s :param retries: 940s Configure the number of retries to allow before raising a 940s :class:`~urllib3.exceptions.MaxRetryError` exception. 940s 940s Pass ``None`` to retry until you receive a response. Pass a 940s :class:`~urllib3.util.retry.Retry` object for fine-grained control 940s over different types of retries. 940s Pass an integer number to retry connection errors that many times, 940s but no other types of errors. Pass zero to never retry. 940s 940s If ``False``, then retries are disabled and any exception is raised 940s immediately. Also, instead of raising a MaxRetryError on redirects, 940s the redirect response will be returned. 940s 940s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 940s 940s :param redirect: 940s If True, automatically handle redirects (status codes 301, 302, 940s 303, 307, 308). Each redirect counts as a retry. Disabling retries 940s will disable redirect, too. 940s 940s :param assert_same_host: 940s If ``True``, will make sure that the host of the pool requests is 940s consistent else will raise HostChangedError. When ``False``, you can 940s use the pool on an HTTP proxy and request foreign hosts. 940s 940s :param timeout: 940s If specified, overrides the default timeout for this one 940s request. It may be a float (in seconds) or an instance of 940s :class:`urllib3.util.Timeout`. 940s 940s :param pool_timeout: 940s If set and the pool is set to block=True, then this method will 940s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 940s connection is available within the time period. 940s 940s :param bool preload_content: 940s If True, the response's body will be preloaded into memory. 940s 940s :param bool decode_content: 940s If True, will attempt to decode the body based on the 940s 'content-encoding' header. 940s 940s :param release_conn: 940s If False, then the urlopen call will not release the connection 940s back into the pool once a response is received (but will release if 940s you read the entire contents of the response such as when 940s `preload_content=True`). This is useful if you're not preloading 940s the response's content immediately. You will need to call 940s ``r.release_conn()`` on the response ``r`` to return the connection 940s back into the pool. If None, it takes the value of ``preload_content`` 940s which defaults to ``True``. 940s 940s :param bool chunked: 940s If True, urllib3 will send the body using chunked transfer 940s encoding. Otherwise, urllib3 will send the body using the standard 940s content-length form. Defaults to False. 940s 940s :param int body_pos: 940s Position to seek to in file-like body in the event of a retry or 940s redirect. Typically this won't need to be set because urllib3 will 940s auto-populate the value when needed. 940s """ 940s parsed_url = parse_url(url) 940s destination_scheme = parsed_url.scheme 940s 940s if headers is None: 940s headers = self.headers 940s 940s if not isinstance(retries, Retry): 940s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 940s 940s if release_conn is None: 940s release_conn = preload_content 940s 940s # Check host 940s if assert_same_host and not self.is_same_host(url): 940s raise HostChangedError(self, url, retries) 940s 940s # Ensure that the URL we're connecting to is properly encoded 940s if url.startswith("/"): 940s url = to_str(_encode_target(url)) 940s else: 940s url = to_str(parsed_url.url) 940s 940s conn = None 940s 940s # Track whether `conn` needs to be released before 940s # returning/raising/recursing. Update this variable if necessary, and 940s # leave `release_conn` constant throughout the function. That way, if 940s # the function recurses, the original value of `release_conn` will be 940s # passed down into the recursive call, and its value will be respected. 940s # 940s # See issue #651 [1] for details. 940s # 940s # [1] 940s release_this_conn = release_conn 940s 940s http_tunnel_required = connection_requires_http_tunnel( 940s self.proxy, self.proxy_config, destination_scheme 940s ) 940s 940s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 940s # have to copy the headers dict so we can safely change it without those 940s # changes being reflected in anyone else's copy. 940s if not http_tunnel_required: 940s headers = headers.copy() # type: ignore[attr-defined] 940s headers.update(self.proxy_headers) # type: ignore[union-attr] 940s 940s # Must keep the exception bound to a separate variable or else Python 3 940s # complains about UnboundLocalError. 940s err = None 940s 940s # Keep track of whether we cleanly exited the except block. This 940s # ensures we do proper cleanup in finally. 940s clean_exit = False 940s 940s # Rewind body position, if needed. Record current position 940s # for future rewinds in the event of a redirect/retry. 940s body_pos = set_file_position(body, body_pos) 940s 940s try: 940s # Request a connection from the queue. 940s timeout_obj = self._get_timeout(timeout) 940s conn = self._get_conn(timeout=pool_timeout) 940s 940s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 940s 940s # Is this a closed/new connection that requires CONNECT tunnelling? 940s if self.proxy is not None and http_tunnel_required and conn.is_closed: 940s try: 940s self._prepare_proxy(conn) 940s except (BaseSSLError, OSError, SocketTimeout) as e: 940s self._raise_timeout( 940s err=e, url=self.proxy.url, timeout_value=conn.timeout 940s ) 940s raise 940s 940s # If we're going to release the connection in ``finally:``, then 940s # the response doesn't need to know about the connection. Otherwise 940s # it will also try to release it and we'll have a double-release 940s # mess. 940s response_conn = conn if not release_conn else None 940s 940s # Make the request on the HTTPConnection object 940s > response = self._make_request( 940s conn, 940s method, 940s url, 940s timeout=timeout_obj, 940s body=body, 940s headers=headers, 940s chunked=chunked, 940s retries=retries, 940s response_conn=response_conn, 940s preload_content=preload_content, 940s decode_content=decode_content, 940s **response_kw, 940s ) 940s 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 940s raise new_e 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 940s self._validate_conn(conn) 940s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 940s conn.connect() 940s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 940s self.sock = sock = self._new_conn() 940s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 940s 940s self = 940s 940s def _new_conn(self) -> socket.socket: 940s """Establish a socket connection and set nodelay settings on it. 940s 940s :return: New socket connection. 940s """ 940s try: 940s sock = connection.create_connection( 940s (self._dns_host, self.port), 940s self.timeout, 940s source_address=self.source_address, 940s socket_options=self.socket_options, 940s ) 940s except socket.gaierror as e: 940s raise NameResolutionError(self.host, self, e) from e 940s except SocketTimeout as e: 940s raise ConnectTimeoutError( 940s self, 940s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 940s ) from e 940s 940s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s def test_basic_encode(): 941s > enc = tiktoken.get_encoding("r50k_base") 941s 941s tests/test_encoding.py:62: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ______________________________ test_encode_empty _______________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s def test_encode_empty(): 941s > enc = tiktoken.get_encoding("r50k_base") 941s 941s tests/test_encoding.py:74: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ______________________________ test_encode_bytes _______________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s def test_encode_bytes(): 941s > enc = tiktoken.get_encoding("cl100k_base") 941s 941s tests/test_encoding.py:79: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s _________________________ test_encode_surrogate_pairs __________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s def test_encode_surrogate_pairs(): 941s > enc = tiktoken.get_encoding("cl100k_base") 941s 941s tests/test_encoding.py:84: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s _________________ test_catastrophically_repetitive[r50k_base] __________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'r50k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s def test_catastrophically_repetitive(make_enc: Callable[[], tiktoken.Encoding]): 941s > enc = make_enc() 941s 941s tests/test_encoding.py:96: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ________________ test_catastrophically_repetitive[cl100k_base] _________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'cl100k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s def test_catastrophically_repetitive(make_enc: Callable[[], tiktoken.Encoding]): 941s > enc = make_enc() 941s 941s tests/test_encoding.py:96: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s _______________________ test_basic_roundtrip[r50k_base] ________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'r50k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s def test_basic_roundtrip(make_enc): 941s > enc = make_enc() 941s 941s tests/test_encoding.py:115: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ______________________ test_basic_roundtrip[cl100k_base] _______________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'cl100k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s def test_basic_roundtrip(make_enc): 941s > enc = make_enc() 941s 941s tests/test_encoding.py:115: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ________________________ test_hyp_roundtrip[r50k_base] _________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'r50k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s > @hypothesis.given(text=st.text()) 941s 941s tests/test_encoding.py:131: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s tests/test_encoding.py:134: in test_hyp_roundtrip 941s enc = make_enc() 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s E Falsifying example: test_hyp_roundtrip( 941s E make_enc=functools.partial(get_encoding, 'r50k_base'), 941s E text='', # or any other generated value 941s E ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s _______________________ test_hyp_roundtrip[cl100k_base] ________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'cl100k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s > @hypothesis.given(text=st.text()) 941s 941s tests/test_encoding.py:131: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s tests/test_encoding.py:134: in test_hyp_roundtrip 941s enc = make_enc() 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s E Falsifying example: test_hyp_roundtrip( 941s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 941s E text='', # or any other generated value 941s E ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ____________________ test_single_token_roundtrip[r50k_base] ____________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'r50k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s def test_single_token_roundtrip(make_enc: Callable[[], tiktoken.Encoding]): 941s > enc = make_enc() 941s 941s tests/test_encoding.py:141: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ___________________ test_single_token_roundtrip[cl100k_base] ___________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL wE: pybuild pybuild:389: test: plugin pyproject failed with: exit code=1: cd /tmp/autopkgtest.74YOef/autopkgtest_tmp/build; python3.13 -m pytest tests 941s I: pybuild base:311: cd /tmp/autopkgtest.74YOef/autopkgtest_tmp/build; python3.12 -m pytest tests 941s e're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'cl100k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s def test_single_token_roundtrip(make_enc: Callable[[], tiktoken.Encoding]): 941s > enc = make_enc() 941s 941s tests/test_encoding.py:141: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ______________________________ test_special_token ______________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s def test_special_token(): 941s > enc = tiktoken.get_encoding("cl100k_base") 941s 941s tests/test_encoding.py:157: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s _____________________ test_hyp_special_ordinary[r50k_base] _____________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'r50k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s > @hypothesis.given(text=st.text()) 941s 941s tests/test_encoding.py:208: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s tests/test_encoding.py:211: in test_hyp_special_ordinary 941s enc = make_enc() 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s E Falsifying example: test_hyp_special_ordinary( 941s E make_enc=functools.partial(get_encoding, 'r50k_base'), 941s E text='', # or any other generated value 941s E ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ____________________ test_hyp_special_ordinary[cl100k_base] ____________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'cl100k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s > @hypothesis.given(text=st.text()) 941s 941s tests/test_encoding.py:208: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s tests/test_encoding.py:211: in test_hyp_special_ordinary 941s enc = make_enc() 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s E Falsifying example: test_hyp_special_ordinary( 941s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 941s E text='', # or any other generated value 941s E ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s _________________________ test_batch_encode[r50k_base] _________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'r50k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s def test_batch_encode(make_enc: Callable[[], tiktoken.Encoding]): 941s > enc = make_enc() 941s 941s tests/test_encoding.py:222: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ________________________ test_batch_encode[cl100k_base] ________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'cl100k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s def test_batch_encode(make_enc: Callable[[], tiktoken.Encoding]): 941s > enc = make_enc() 941s 941s tests/test_encoding.py:222: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s _____________________ test_hyp_batch_roundtrip[r50k_base] ______________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'r50k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s > @hypothesis.given(batch=st.lists(st.text())) 941s 941s tests/test_encoding.py:237: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s tests/test_encoding.py:240: in test_hyp_batch_roundtrip 941s enc = make_enc() 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s E Falsifying example: test_hyp_batch_roundtrip( 941s E make_enc=functools.partial(get_encoding, 'r50k_base'), 941s E batch=[], # or any other generated value 941s E ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ____________________ test_hyp_batch_roundtrip[cl100k_base] _____________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'cl100k_base') 941s 941s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 941s > @hypothesis.given(batch=st.lists(st.text())) 941s 941s tests/test_encoding.py:237: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s tests/test_encoding.py:240: in test_hyp_batch_roundtrip 941s enc = make_enc() 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s E Falsifying example: test_hyp_batch_roundtrip( 941s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 941s E batch=[], # or any other generated value 941s E ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ___________________________ test_encoding_for_model ____________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s def test_encoding_for_model(): 941s > enc = tiktoken.encoding_for_model("gpt2") 941s 941s tests/test_misc.py:8: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/model.py:105: in encoding_for_model 941s return get_encoding(encoding_name_for_model(model_name)) 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 941s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 941s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ________________________ test_hyp_offsets[cl100k_base] _________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s make_enc = functools.partial(, 'cl100k_base') 941s 941s @pytest.mark.parametrize("make_enc", SOME_ENCODING_FACTORIES) 941s > @hypothesis.given(data=st.data()) 941s 941s tests/test_offsets.py:29: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s tests/test_offsets.py:32: in test_hyp_offsets 941s enc = make_enc() 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s E Falsifying example: test_hyp_offsets( 941s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 941s E data=data(...), 941s E ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ______________________________ test_basic_offsets ______________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s def test_basic_offsets(): 941s > enc = tiktoken.get_encoding("cl100k_base") 941s 941s tests/test_offsets.py:50: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s _________________________________ test_pickle __________________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s def test_pickle(): 941s import pickle 941s 941s > enc_old = tiktoken.get_encoding("r50k_base") 941s 941s tests/test_pickle.py:7: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 941s mergeable_ranks = load_tiktoken_bpe( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 941s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s _________________________________ test_simple __________________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s def test_simple(): 941s # Note that there are more actual tests, they're just not currently public :-) 941s > enc = tiktoken.get_encoding("gpt2") 941s 941s tests/test_simple_public.py:9: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 941s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 941s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s ___________________________ test_encoding_for_model ____________________________ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s > sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 941s raise err 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 941s source_address = None, socket_options = [(6, 1, 1)] 941s 941s def create_connection( 941s address: tuple[str, int], 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s source_address: tuple[str, int] | None = None, 941s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 941s ) -> socket.socket: 941s """Connect to *address* and return the socket object. 941s 941s Convenience function. Connect to *address* (a 2-tuple ``(host, 941s port)``) and return the socket object. Passing the optional 941s *timeout* parameter will set the timeout on the socket instance 941s before attempting to connect. If no *timeout* is supplied, the 941s global default timeout setting returned by :func:`socket.getdefaulttimeout` 941s is used. If *source_address* is set it must be a tuple of (host, port) 941s for the socket to bind as a source address before making the connection. 941s An host of '' or port 0 tells the OS to use the default. 941s """ 941s 941s host, port = address 941s if host.startswith("["): 941s host = host.strip("[]") 941s err = None 941s 941s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 941s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 941s # The original create_connection function always returns all records. 941s family = allowed_gai_family() 941s 941s try: 941s host.encode("idna") 941s except UnicodeError: 941s raise LocationParseError(f"'{host}', label empty or too long") from None 941s 941s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 941s af, socktype, proto, canonname, sa = res 941s sock = None 941s try: 941s sock = socket.socket(af, socktype, proto) 941s 941s # If provided, set socket level options before connecting. 941s _set_socket_options(sock, socket_options) 941s 941s if timeout is not _DEFAULT_TIMEOUT: 941s sock.settimeout(timeout) 941s if source_address: 941s sock.bind(source_address) 941s > sock.connect(sa) 941s E ConnectionRefusedError: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 941s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 941s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s redirect = False, assert_same_host = False 941s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 941s release_conn = False, chunked = False, body_pos = None, preload_content = False 941s decode_content = False, response_kw = {} 941s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 941s destination_scheme = None, conn = None, release_this_conn = True 941s http_tunnel_required = False, err = None, clean_exit = False 941s 941s def urlopen( # type: ignore[override] 941s self, 941s method: str, 941s url: str, 941s body: _TYPE_BODY | None = None, 941s headers: typing.Mapping[str, str] | None = None, 941s retries: Retry | bool | int | None = None, 941s redirect: bool = True, 941s assert_same_host: bool = True, 941s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 941s pool_timeout: int | None = None, 941s release_conn: bool | None = None, 941s chunked: bool = False, 941s body_pos: _TYPE_BODY_POSITION | None = None, 941s preload_content: bool = True, 941s decode_content: bool = True, 941s **response_kw: typing.Any, 941s ) -> BaseHTTPResponse: 941s """ 941s Get a connection from the pool and perform an HTTP request. This is the 941s lowest level call for making a request, so you'll need to specify all 941s the raw details. 941s 941s .. note:: 941s 941s More commonly, it's appropriate to use a convenience method 941s such as :meth:`request`. 941s 941s .. note:: 941s 941s `release_conn` will only behave as expected if 941s `preload_content=False` because we want to make 941s `preload_content=False` the default behaviour someday soon without 941s breaking backwards compatibility. 941s 941s :param method: 941s HTTP request method (such as GET, POST, PUT, etc.) 941s 941s :param url: 941s The URL to perform the request on. 941s 941s :param body: 941s Data to send in the request body, either :class:`str`, :class:`bytes`, 941s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 941s 941s :param headers: 941s Dictionary of custom headers to send, such as User-Agent, 941s If-None-Match, etc. If None, pool headers are used. If provided, 941s these headers completely replace any pool-specific headers. 941s 941s :param retries: 941s Configure the number of retries to allow before raising a 941s :class:`~urllib3.exceptions.MaxRetryError` exception. 941s 941s Pass ``None`` to retry until you receive a response. Pass a 941s :class:`~urllib3.util.retry.Retry` object for fine-grained control 941s over different types of retries. 941s Pass an integer number to retry connection errors that many times, 941s but no other types of errors. Pass zero to never retry. 941s 941s If ``False``, then retries are disabled and any exception is raised 941s immediately. Also, instead of raising a MaxRetryError on redirects, 941s the redirect response will be returned. 941s 941s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 941s 941s :param redirect: 941s If True, automatically handle redirects (status codes 301, 302, 941s 303, 307, 308). Each redirect counts as a retry. Disabling retries 941s will disable redirect, too. 941s 941s :param assert_same_host: 941s If ``True``, will make sure that the host of the pool requests is 941s consistent else will raise HostChangedError. When ``False``, you can 941s use the pool on an HTTP proxy and request foreign hosts. 941s 941s :param timeout: 941s If specified, overrides the default timeout for this one 941s request. It may be a float (in seconds) or an instance of 941s :class:`urllib3.util.Timeout`. 941s 941s :param pool_timeout: 941s If set and the pool is set to block=True, then this method will 941s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 941s connection is available within the time period. 941s 941s :param bool preload_content: 941s If True, the response's body will be preloaded into memory. 941s 941s :param bool decode_content: 941s If True, will attempt to decode the body based on the 941s 'content-encoding' header. 941s 941s :param release_conn: 941s If False, then the urlopen call will not release the connection 941s back into the pool once a response is received (but will release if 941s you read the entire contents of the response such as when 941s `preload_content=True`). This is useful if you're not preloading 941s the response's content immediately. You will need to call 941s ``r.release_conn()`` on the response ``r`` to return the connection 941s back into the pool. If None, it takes the value of ``preload_content`` 941s which defaults to ``True``. 941s 941s :param bool chunked: 941s If True, urllib3 will send the body using chunked transfer 941s encoding. Otherwise, urllib3 will send the body using the standard 941s content-length form. Defaults to False. 941s 941s :param int body_pos: 941s Position to seek to in file-like body in the event of a retry or 941s redirect. Typically this won't need to be set because urllib3 will 941s auto-populate the value when needed. 941s """ 941s parsed_url = parse_url(url) 941s destination_scheme = parsed_url.scheme 941s 941s if headers is None: 941s headers = self.headers 941s 941s if not isinstance(retries, Retry): 941s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 941s 941s if release_conn is None: 941s release_conn = preload_content 941s 941s # Check host 941s if assert_same_host and not self.is_same_host(url): 941s raise HostChangedError(self, url, retries) 941s 941s # Ensure that the URL we're connecting to is properly encoded 941s if url.startswith("/"): 941s url = to_str(_encode_target(url)) 941s else: 941s url = to_str(parsed_url.url) 941s 941s conn = None 941s 941s # Track whether `conn` needs to be released before 941s # returning/raising/recursing. Update this variable if necessary, and 941s # leave `release_conn` constant throughout the function. That way, if 941s # the function recurses, the original value of `release_conn` will be 941s # passed down into the recursive call, and its value will be respected. 941s # 941s # See issue #651 [1] for details. 941s # 941s # [1] 941s release_this_conn = release_conn 941s 941s http_tunnel_required = connection_requires_http_tunnel( 941s self.proxy, self.proxy_config, destination_scheme 941s ) 941s 941s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 941s # have to copy the headers dict so we can safely change it without those 941s # changes being reflected in anyone else's copy. 941s if not http_tunnel_required: 941s headers = headers.copy() # type: ignore[attr-defined] 941s headers.update(self.proxy_headers) # type: ignore[union-attr] 941s 941s # Must keep the exception bound to a separate variable or else Python 3 941s # complains about UnboundLocalError. 941s err = None 941s 941s # Keep track of whether we cleanly exited the except block. This 941s # ensures we do proper cleanup in finally. 941s clean_exit = False 941s 941s # Rewind body position, if needed. Record current position 941s # for future rewinds in the event of a redirect/retry. 941s body_pos = set_file_position(body, body_pos) 941s 941s try: 941s # Request a connection from the queue. 941s timeout_obj = self._get_timeout(timeout) 941s conn = self._get_conn(timeout=pool_timeout) 941s 941s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 941s 941s # Is this a closed/new connection that requires CONNECT tunnelling? 941s if self.proxy is not None and http_tunnel_required and conn.is_closed: 941s try: 941s self._prepare_proxy(conn) 941s except (BaseSSLError, OSError, SocketTimeout) as e: 941s self._raise_timeout( 941s err=e, url=self.proxy.url, timeout_value=conn.timeout 941s ) 941s raise 941s 941s # If we're going to release the connection in ``finally:``, then 941s # the response doesn't need to know about the connection. Otherwise 941s # it will also try to release it and we'll have a double-release 941s # mess. 941s response_conn = conn if not release_conn else None 941s 941s # Make the request on the HTTPConnection object 941s > response = self._make_request( 941s conn, 941s method, 941s url, 941s timeout=timeout_obj, 941s body=body, 941s headers=headers, 941s chunked=chunked, 941s retries=retries, 941s response_conn=response_conn, 941s preload_content=preload_content, 941s decode_content=decode_content, 941s **response_kw, 941s ) 941s 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 941s raise new_e 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 941s self._validate_conn(conn) 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 941s conn.connect() 941s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 941s self.sock = sock = self._new_conn() 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s 941s def _new_conn(self) -> socket.socket: 941s """Establish a socket connection and set nodelay settings on it. 941s 941s :return: New socket connection. 941s """ 941s try: 941s sock = connection.create_connection( 941s (self._dns_host, self.port), 941s self.timeout, 941s source_address=self.source_address, 941s socket_options=self.socket_options, 941s ) 941s except socket.gaierror as e: 941s raise NameResolutionError(self.host, self, e) from e 941s except SocketTimeout as e: 941s raise ConnectTimeoutError( 941s self, 941s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 941s ) from e 941s 941s except OSError as e: 941s > raise NewConnectionError( 941s self, f"Failed to establish a new connection: {e}" 941s ) from e 941s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 941s 941s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 941s 941s The above exception was the direct cause of the following exception: 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s > resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:667: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 941s retries = retries.increment( 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 941s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 941s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 941s _pool = 941s _stacktrace = 941s 941s def increment( 941s self, 941s method: str | None = None, 941s url: str | None = None, 941s response: BaseHTTPResponse | None = None, 941s error: Exception | None = None, 941s _pool: ConnectionPool | None = None, 941s _stacktrace: TracebackType | None = None, 941s ) -> Retry: 941s """Return a new Retry object with incremented retry counters. 941s 941s :param response: A response object, or None, if the server did not 941s return a response. 941s :type response: :class:`~urllib3.response.BaseHTTPResponse` 941s :param Exception error: An error encountered during the request, or 941s None if the response was received successfully. 941s 941s :return: A new ``Retry`` object. 941s """ 941s if self.total is False and error: 941s # Disabled, indicate to re-raise the error. 941s raise reraise(type(error), error, _stacktrace) 941s 941s total = self.total 941s if total is not None: 941s total -= 1 941s 941s connect = self.connect 941s read = self.read 941s redirect = self.redirect 941s status_count = self.status 941s other = self.other 941s cause = "unknown" 941s status = None 941s redirect_location = None 941s 941s if error and self._is_connection_error(error): 941s # Connect retry? 941s if connect is False: 941s raise reraise(type(error), error, _stacktrace) 941s elif connect is not None: 941s connect -= 1 941s 941s elif error and self._is_read_error(error): 941s # Read retry? 941s if read is False or method is None or not self._is_method_retryable(method): 941s raise reraise(type(error), error, _stacktrace) 941s elif read is not None: 941s read -= 1 941s 941s elif error: 941s # Other retry? 941s if other is not None: 941s other -= 1 941s 941s elif response and response.get_redirect_location(): 941s # Redirect retry? 941s if redirect is not None: 941s redirect -= 1 941s cause = "too many redirects" 941s response_redirect_location = response.get_redirect_location() 941s if response_redirect_location: 941s redirect_location = response_redirect_location 941s status = response.status 941s 941s else: 941s # Incrementing because of a server error like a 500 in 941s # status_forcelist and the given method is in the allowed_methods 941s cause = ResponseError.GENERIC_ERROR 941s if response and response.status: 941s if status_count is not None: 941s status_count -= 1 941s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 941s status = response.status 941s 941s history = self.history + ( 941s RequestHistory(method, url, error, status, redirect_location), 941s ) 941s 941s new_retry = self.new( 941s total=total, 941s connect=connect, 941s read=read, 941s redirect=redirect, 941s status=status_count, 941s other=other, 941s history=history, 941s ) 941s 941s if new_retry.is_exhausted(): 941s reason = error or ResponseError(cause) 941s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 941s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 941s 941s During handling of the above exception, another exception occurred: 941s 941s def test_encoding_for_model(): 941s > enc = tiktoken.encoding_for_model("gpt2") 941s 941s tests/test_simple_public.py:26: 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s /usr/lib/python3/dist-packages/tiktoken/model.py:105: in encoding_for_model 941s return get_encoding(encoding_name_for_model(model_name)) 941s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 941s enc = Encoding(**constructor()) 941s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 941s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 941s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 941s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 941s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 941s contents = read_file(blobpath) 941s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 941s resp = requests.get(blobpath) 941s /usr/lib/python3/dist-packages/requests/api.py:73: in get 941s return request("get", url, params=params, **kwargs) 941s /usr/lib/python3/dist-packages/requests/api.py:59: in request 941s return session.request(method=method, url=url, **kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 941s resp = self.send(prep, **send_kwargs) 941s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 941s r = adapter.send(request, **kwargs) 941s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 941s 941s self = 941s request = , stream = False 941s timeout = Timeout(connect=None, read=None, total=None), verify = True 941s cert = None, proxies = OrderedDict() 941s 941s def send( 941s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 941s ): 941s """Sends PreparedRequest object. Returns Response object. 941s 941s :param request: The :class:`PreparedRequest ` being sent. 941s :param stream: (optional) Whether to stream the request content. 941s :param timeout: (optional) How long to wait for the server to send 941s data before giving up, as a float, or a :ref:`(connect timeout, 941s read timeout) ` tuple. 941s :type timeout: float or tuple or urllib3 Timeout object 941s :param verify: (optional) Either a boolean, in which case it controls whether 941s we verify the server's TLS certificate, or a string, in which case it 941s must be a path to a CA bundle to use 941s :param cert: (optional) Any user-provided SSL certificate to be trusted. 941s :param proxies: (optional) The proxies dictionary to apply to the request. 941s :rtype: requests.Response 941s """ 941s 941s try: 941s conn = self.get_connection_with_tls_context( 941s request, verify, proxies=proxies, cert=cert 941s ) 941s except LocationValueError as e: 941s raise InvalidURL(e, request=request) 941s 941s self.cert_verify(conn, request.url, verify, cert) 941s url = self.request_url(request, proxies) 941s self.add_headers( 941s request, 941s stream=stream, 941s timeout=timeout, 941s verify=verify, 941s cert=cert, 941s proxies=proxies, 941s ) 941s 941s chunked = not (request.body is None or "Content-Length" in request.headers) 941s 941s if isinstance(timeout, tuple): 941s try: 941s connect, read = timeout 941s timeout = TimeoutSauce(connect=connect, read=read) 941s except ValueError: 941s raise ValueError( 941s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 941s f"or a single float to set both timeouts to the same value." 941s ) 941s elif isinstance(timeout, TimeoutSauce): 941s pass 941s else: 941s timeout = TimeoutSauce(connect=timeout, read=timeout) 941s 941s try: 941s resp = conn.urlopen( 941s method=request.method, 941s url=url, 941s body=request.body, 941s headers=request.headers, 941s redirect=False, 941s assert_same_host=False, 941s preload_content=False, 941s decode_content=False, 941s retries=self.max_retries, 941s timeout=timeout, 941s chunked=chunked, 941s ) 941s 941s except (ProtocolError, OSError) as err: 941s raise ConnectionError(err, request=request) 941s 941s except MaxRetryError as e: 941s if isinstance(e.reason, ConnectTimeoutError): 941s # TODO: Remove this in 3.0.0: see #2811 941s if not isinstance(e.reason, NewConnectionError): 941s raise ConnectTimeout(e, request=request) 941s 941s if isinstance(e.reason, ResponseError): 941s raise RetryError(e, request=request) 941s 941s if isinstance(e.reason, _ProxyError): 941s raise ProxyError(e, request=request) 941s 941s if isinstance(e.reason, _SSLError): 941s # This branch is for urllib3 v1.22 and later. 941s raise SSLError(e, request=request) 941s 941s > raise ConnectionError(e, request=request) 941s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 941s 941s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 941s =========================== short test summary info ============================ 941s FAILED tests/test_encoding.py::test_simple - requests.exceptions.ConnectionEr... 941s FAILED tests/test_encoding.py::test_simple_repeated - requests.exceptions.Con... 941s FAILED tests/test_encoding.py::test_simple_regex - requests.exceptions.Connec... 941s FAILED tests/test_encoding.py::test_basic_encode - requests.exceptions.Connec... 941s FAILED tests/test_encoding.py::test_encode_empty - requests.exceptions.Connec... 941s FAILED tests/test_encoding.py::test_encode_bytes - requests.exceptions.Connec... 941s FAILED tests/test_encoding.py::test_encode_surrogate_pairs - requests.excepti... 941s FAILED tests/test_encoding.py::test_catastrophically_repetitive[r50k_base] - ... 941s FAILED tests/test_encoding.py::test_catastrophically_repetitive[cl100k_base] 941s FAILED tests/test_encoding.py::test_basic_roundtrip[r50k_base] - requests.exc... 941s FAILED tests/test_encoding.py::test_basic_roundtrip[cl100k_base] - requests.e... 941s FAILED tests/test_encoding.py::test_hyp_roundtrip[r50k_base] - requests.excep... 941s FAILED tests/test_encoding.py::test_hyp_roundtrip[cl100k_base] - requests.exc... 941s FAILED tests/test_encoding.py::test_single_token_roundtrip[r50k_base] - reque... 941s FAILED tests/test_encoding.py::test_single_token_roundtrip[cl100k_base] - req... 941s FAILED tests/test_encoding.py::test_special_token - requests.exceptions.Conne... 941s FAILED tests/test_encoding.py::test_hyp_special_ordinary[r50k_base] - request... 941s FAILED tests/test_encoding.py::test_hyp_special_ordinary[cl100k_base] - reque... 941s FAILED tests/test_encoding.py::test_batch_encode[r50k_base] - requests.except... 941s FAILED tests/test_encoding.py::test_batch_encode[cl100k_base] - requests.exce... 941s FAILED tests/test_encoding.py::test_hyp_batch_roundtrip[r50k_base] - requests... 941s FAILED tests/test_encoding.py::test_hyp_batch_roundtrip[cl100k_base] - reques... 941s FAILED tests/test_misc.py::test_encoding_for_model - requests.exceptions.Conn... 941s FAILED tests/test_offsets.py::test_hyp_offsets[cl100k_base] - requests.except... 941s FAILED tests/test_offsets.py::test_basic_offsets - requests.exceptions.Connec... 941s FAILED tests/test_pickle.py::test_pickle - requests.exceptions.ConnectionErro... 941s FAILED tests/test_simple_public.py::test_simple - requests.exceptions.Connect... 941s FAILED tests/test_simple_public.py::test_encoding_for_model - requests.except... 941s =================== 28 failed, 2 passed in 574.68s (0:09:34) =================== 941s ============================= test session starts ============================== 941s platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0 941s rootdir: /tmp/autopkgtest.74YOef/autopkgtest_tmp/build 941s configfile: pyproject.toml 941s plugins: typeguard-4.4.1, hypothesis-6.119.3 941s collected 30 items 941s 968s tests/test_encoding.py FFFFFFFFFFFFFFFFFFFFFF [ 73%] 969s tests/test_misc.py F. [ 80%] 972s tests/test_offsets.py FF [ 86%] 972s tests/test_pickle.py F [ 90%] 975s tests/test_simple_public.py FF. [100%] 975s 975s =================================== FAILURES =================================== 975s _________________________________ test_simple __________________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_simple(): 975s > enc = tiktoken.get_encoding("gpt2") 975s 975s tests/test_encoding.py:15: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 975s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 975s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s _____________________________ test_simple_repeated _____________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_simple_repeated(): 975s > enc = tiktoken.get_encoding("gpt2") 975s 975s tests/test_encoding.py:32: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 975s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 975s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ______________________________ test_simple_regex _______________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_simple_regex(): 975s > enc = tiktoken.get_encoding("cl100k_base") 975s 975s tests/test_encoding.py:53: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ______________________________ test_basic_encode _______________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_basic_encode(): 975s > enc = tiktoken.get_encoding("r50k_base") 975s 975s tests/test_encoding.py:62: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ______________________________ test_encode_empty _______________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_encode_empty(): 975s > enc = tiktoken.get_encoding("r50k_base") 975s 975s tests/test_encoding.py:74: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ______________________________ test_encode_bytes _______________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_encode_bytes(): 975s > enc = tiktoken.get_encoding("cl100k_base") 975s 975s tests/test_encoding.py:79: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s _________________________ test_encode_surrogate_pairs __________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_encode_surrogate_pairs(): 975s > enc = tiktoken.get_encoding("cl100k_base") 975s 975s tests/test_encoding.py:84: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s _________________ test_catastrophically_repetitive[r50k_base] __________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'r50k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s def test_catastrophically_repetitive(make_enc: Callable[[], tiktoken.Encoding]): 975s > enc = make_enc() 975s 975s tests/test_encoding.py:96: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ________________ test_catastrophically_repetitive[cl100k_base] _________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'cl100k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s def test_catastrophically_repetitive(make_enc: Callable[[], tiktoken.Encoding]): 975s > enc = make_enc() 975s 975s tests/test_encoding.py:96: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s _______________________ test_basic_roundtrip[r50k_base] ________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'r50k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s def test_basic_roundtrip(make_enc): 975s > enc = make_enc() 975s 975s tests/test_encoding.py:115: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ______________________ test_basic_roundtrip[cl100k_base] _______________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'cl100k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s def test_basic_roundtrip(make_enc): 975s > enc = make_enc() 975s 975s tests/test_encoding.py:115: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ________________________ test_hyp_roundtrip[r50k_base] _________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'r50k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s > @hypothesis.given(text=st.text()) 975s 975s tests/test_encoding.py:131: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s tests/test_encoding.py:134: in test_hyp_roundtrip 975s enc = make_enc() 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s E Falsifying example: test_hyp_roundtrip( 975s E make_enc=functools.partial(get_encoding, 'r50k_base'), 975s E text='', 975s E ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s _______________________ test_hyp_roundtrip[cl100k_base] ________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'cl100k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s > @hypothesis.given(text=st.text()) 975s 975s tests/test_encoding.py:131: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s tests/test_encoding.py:134: in test_hyp_roundtrip 975s enc = make_enc() 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s E Falsifying example: test_hyp_roundtrip( 975s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 975s E text='', 975s E ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ____________________ test_single_token_roundtrip[r50k_base] ____________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'r50k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s def test_single_token_roundtrip(make_enc: Callable[[], tiktoken.Encoding]): 975s > enc = make_enc() 975s 975s tests/test_encoding.py:141: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ___________________ test_single_token_roundtrip[cl100k_base] ___________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'cl100k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s def test_single_token_roundtrip(make_enc: Callable[[], tiktoken.Encoding]): 975s > enc = make_enc() 975s 975s tests/test_encoding.py:141: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ______________________________ test_special_token ______________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_special_token(): 975s > enc = tiktoken.get_encoding("cl100k_base") 975s 975s tests/test_encoding.py:157: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s _____________________ test_hyp_special_ordinary[r50k_base] _____________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'r50k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s > @hypothesis.given(text=st.text()) 975s 975s tests/test_encoding.py:208: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s tests/test_encoding.py:211: in test_hyp_special_ordinary 975s enc = make_enc() 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s E Falsifying example: test_hyp_special_ordinary( 975s E make_enc=functools.partial(get_encoding, 'r50k_base'), 975s E text='', 975s E ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ____________________ test_hyp_special_ordinary[cl100k_base] ____________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'cl100k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s > @hypothesis.given(text=st.text()) 975s 975s tests/test_encoding.py:208: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s tests/test_encoding.py:211: in test_hyp_special_ordinary 975s enc = make_enc() 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s E Falsifying example: test_hyp_special_ordinary( 975s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 975s E text='', 975s E ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s _________________________ test_batch_encode[r50k_base] _________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'r50k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s def test_batch_encode(make_enc: Callable[[], tiktoken.Encoding]): 975s > enc = make_enc() 975s 975s tests/test_encoding.py:222: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ________________________ test_batch_encode[cl100k_base] ________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'cl100k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s def test_batch_encode(make_enc: Callable[[], tiktoken.Encoding]): 975s > enc = make_enc() 975s 975s tests/test_encoding.py:222: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s _____________________ test_hyp_batch_roundtrip[r50k_base] ______________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'r50k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s > @hypothesis.given(batch=st.lists(st.text())) 975s 975s tests/test_encoding.py:237: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s tests/test_encoding.py:240: in test_hyp_batch_roundtrip 975s enc = make_enc() 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s E Falsifying example: test_hyp_batch_roundtrip( 975s E make_enc=functools.partial(get_encoding, 'r50k_base'), 975s E batch=[], 975s E ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ____________________ test_hyp_batch_roundtrip[cl100k_base] _____________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'cl100k_base') 975s 975s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 975s > @hypothesis.given(batch=st.lists(st.text())) 975s 975s tests/test_encoding.py:237: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s tests/test_encoding.py:240: in test_hyp_batch_roundtrip 975s enc = make_enc() 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s E Falsifying example: test_hyp_batch_roundtrip( 975s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 975s E batch=[], 975s E ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ___________________________ test_encoding_for_model ____________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_encoding_for_model(): 975s > enc = tiktoken.encoding_for_model("gpt2") 975s 975s tests/test_misc.py:8: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/model.py:105: in encoding_for_model 975s return get_encoding(encoding_name_for_model(model_name)) 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 975s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 975s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ________________________ test_hyp_offsets[cl100k_base] _________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s make_enc = functools.partial(, 'cl100k_base') 975s 975s @pytest.mark.parametrize("make_enc", SOME_ENCODING_FACTORIES) 975s > @hypothesis.given(data=st.data()) 975s 975s tests/test_offsets.py:29: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s tests/test_offsets.py:32: in test_hyp_offsets 975s enc = make_enc() 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s E Falsifying example: test_hyp_offsets( 975s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 975s E data=data(...), 975s E ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ______________________________ test_basic_offsets ______________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s E: pybuild pybuild:389: test: plugin pyproject failed with: exit code=1: cd /tmp/autopkgtest.74YOef/autopkgtest_tmp/build; python3.12 -m pytest tests 975s pybuild-autopkgtest: error: pybuild --autopkgtest --test-pytest -i python{version} -p "3.13 3.12" returned exit code 13 975s make: *** [/tmp/WA3gETI2JB/run:4: pybuild-autopkgtest] Error 25 975s pybuild-autopkgtest: error: /tmp/WA3gETI2JB/run pybuild-autopkgtest returned exit code 2 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_basic_offsets(): 975s > enc = tiktoken.get_encoding("cl100k_base") 975s 975s tests/test_offsets.py:50: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/cl100k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s _________________________________ test_pickle __________________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_pickle(): 975s import pickle 975s 975s > enc_old = tiktoken.get_encoding("r50k_base") 975s 975s tests/test_pickle.py:7: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 975s mergeable_ranks = load_tiktoken_bpe( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 975s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /encodings/r50k_base.tiktoken (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s _________________________________ test_simple __________________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_simple(): 975s # Note that there are more actual tests, they're just not currently public :-) 975s > enc = tiktoken.get_encoding("gpt2") 975s 975s tests/test_simple_public.py:9: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 975s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 975s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s ___________________________ test_encoding_for_model ____________________________ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s > sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 975s raise err 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 975s source_address = None, socket_options = [(6, 1, 1)] 975s 975s def create_connection( 975s address: tuple[str, int], 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s source_address: tuple[str, int] | None = None, 975s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 975s ) -> socket.socket: 975s """Connect to *address* and return the socket object. 975s 975s Convenience function. Connect to *address* (a 2-tuple ``(host, 975s port)``) and return the socket object. Passing the optional 975s *timeout* parameter will set the timeout on the socket instance 975s before attempting to connect. If no *timeout* is supplied, the 975s global default timeout setting returned by :func:`socket.getdefaulttimeout` 975s is used. If *source_address* is set it must be a tuple of (host, port) 975s for the socket to bind as a source address before making the connection. 975s An host of '' or port 0 tells the OS to use the default. 975s """ 975s 975s host, port = address 975s if host.startswith("["): 975s host = host.strip("[]") 975s err = None 975s 975s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 975s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 975s # The original create_connection function always returns all records. 975s family = allowed_gai_family() 975s 975s try: 975s host.encode("idna") 975s except UnicodeError: 975s raise LocationParseError(f"'{host}', label empty or too long") from None 975s 975s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 975s af, socktype, proto, canonname, sa = res 975s sock = None 975s try: 975s sock = socket.socket(af, socktype, proto) 975s 975s # If provided, set socket level options before connecting. 975s _set_socket_options(sock, socket_options) 975s 975s if timeout is not _DEFAULT_TIMEOUT: 975s sock.settimeout(timeout) 975s if source_address: 975s sock.bind(source_address) 975s > sock.connect(sa) 975s E ConnectionRefusedError: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 975s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 975s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s redirect = False, assert_same_host = False 975s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 975s release_conn = False, chunked = False, body_pos = None, preload_content = False 975s decode_content = False, response_kw = {} 975s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 975s destination_scheme = None, conn = None, release_this_conn = True 975s http_tunnel_required = False, err = None, clean_exit = False 975s 975s def urlopen( # type: ignore[override] 975s self, 975s method: str, 975s url: str, 975s body: _TYPE_BODY | None = None, 975s headers: typing.Mapping[str, str] | None = None, 975s retries: Retry | bool | int | None = None, 975s redirect: bool = True, 975s assert_same_host: bool = True, 975s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 975s pool_timeout: int | None = None, 975s release_conn: bool | None = None, 975s chunked: bool = False, 975s body_pos: _TYPE_BODY_POSITION | None = None, 975s preload_content: bool = True, 975s decode_content: bool = True, 975s **response_kw: typing.Any, 975s ) -> BaseHTTPResponse: 975s """ 975s Get a connection from the pool and perform an HTTP request. This is the 975s lowest level call for making a request, so you'll need to specify all 975s the raw details. 975s 975s .. note:: 975s 975s More commonly, it's appropriate to use a convenience method 975s such as :meth:`request`. 975s 975s .. note:: 975s 975s `release_conn` will only behave as expected if 975s `preload_content=False` because we want to make 975s `preload_content=False` the default behaviour someday soon without 975s breaking backwards compatibility. 975s 975s :param method: 975s HTTP request method (such as GET, POST, PUT, etc.) 975s 975s :param url: 975s The URL to perform the request on. 975s 975s :param body: 975s Data to send in the request body, either :class:`str`, :class:`bytes`, 975s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 975s 975s :param headers: 975s Dictionary of custom headers to send, such as User-Agent, 975s If-None-Match, etc. If None, pool headers are used. If provided, 975s these headers completely replace any pool-specific headers. 975s 975s :param retries: 975s Configure the number of retries to allow before raising a 975s :class:`~urllib3.exceptions.MaxRetryError` exception. 975s 975s Pass ``None`` to retry until you receive a response. Pass a 975s :class:`~urllib3.util.retry.Retry` object for fine-grained control 975s over different types of retries. 975s Pass an integer number to retry connection errors that many times, 975s but no other types of errors. Pass zero to never retry. 975s 975s If ``False``, then retries are disabled and any exception is raised 975s immediately. Also, instead of raising a MaxRetryError on redirects, 975s the redirect response will be returned. 975s 975s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 975s 975s :param redirect: 975s If True, automatically handle redirects (status codes 301, 302, 975s 303, 307, 308). Each redirect counts as a retry. Disabling retries 975s will disable redirect, too. 975s 975s :param assert_same_host: 975s If ``True``, will make sure that the host of the pool requests is 975s consistent else will raise HostChangedError. When ``False``, you can 975s use the pool on an HTTP proxy and request foreign hosts. 975s 975s :param timeout: 975s If specified, overrides the default timeout for this one 975s request. It may be a float (in seconds) or an instance of 975s :class:`urllib3.util.Timeout`. 975s 975s :param pool_timeout: 975s If set and the pool is set to block=True, then this method will 975s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 975s connection is available within the time period. 975s 975s :param bool preload_content: 975s If True, the response's body will be preloaded into memory. 975s 975s :param bool decode_content: 975s If True, will attempt to decode the body based on the 975s 'content-encoding' header. 975s 975s :param release_conn: 975s If False, then the urlopen call will not release the connection 975s back into the pool once a response is received (but will release if 975s you read the entire contents of the response such as when 975s `preload_content=True`). This is useful if you're not preloading 975s the response's content immediately. You will need to call 975s ``r.release_conn()`` on the response ``r`` to return the connection 975s back into the pool. If None, it takes the value of ``preload_content`` 975s which defaults to ``True``. 975s 975s :param bool chunked: 975s If True, urllib3 will send the body using chunked transfer 975s encoding. Otherwise, urllib3 will send the body using the standard 975s content-length form. Defaults to False. 975s 975s :param int body_pos: 975s Position to seek to in file-like body in the event of a retry or 975s redirect. Typically this won't need to be set because urllib3 will 975s auto-populate the value when needed. 975s """ 975s parsed_url = parse_url(url) 975s destination_scheme = parsed_url.scheme 975s 975s if headers is None: 975s headers = self.headers 975s 975s if not isinstance(retries, Retry): 975s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 975s 975s if release_conn is None: 975s release_conn = preload_content 975s 975s # Check host 975s if assert_same_host and not self.is_same_host(url): 975s raise HostChangedError(self, url, retries) 975s 975s # Ensure that the URL we're connecting to is properly encoded 975s if url.startswith("/"): 975s url = to_str(_encode_target(url)) 975s else: 975s url = to_str(parsed_url.url) 975s 975s conn = None 975s 975s # Track whether `conn` needs to be released before 975s # returning/raising/recursing. Update this variable if necessary, and 975s # leave `release_conn` constant throughout the function. That way, if 975s # the function recurses, the original value of `release_conn` will be 975s # passed down into the recursive call, and its value will be respected. 975s # 975s # See issue #651 [1] for details. 975s # 975s # [1] 975s release_this_conn = release_conn 975s 975s http_tunnel_required = connection_requires_http_tunnel( 975s self.proxy, self.proxy_config, destination_scheme 975s ) 975s 975s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 975s # have to copy the headers dict so we can safely change it without those 975s # changes being reflected in anyone else's copy. 975s if not http_tunnel_required: 975s headers = headers.copy() # type: ignore[attr-defined] 975s headers.update(self.proxy_headers) # type: ignore[union-attr] 975s 975s # Must keep the exception bound to a separate variable or else Python 3 975s # complains about UnboundLocalError. 975s err = None 975s 975s # Keep track of whether we cleanly exited the except block. This 975s # ensures we do proper cleanup in finally. 975s clean_exit = False 975s 975s # Rewind body position, if needed. Record current position 975s # for future rewinds in the event of a redirect/retry. 975s body_pos = set_file_position(body, body_pos) 975s 975s try: 975s # Request a connection from the queue. 975s timeout_obj = self._get_timeout(timeout) 975s conn = self._get_conn(timeout=pool_timeout) 975s 975s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 975s 975s # Is this a closed/new connection that requires CONNECT tunnelling? 975s if self.proxy is not None and http_tunnel_required and conn.is_closed: 975s try: 975s self._prepare_proxy(conn) 975s except (BaseSSLError, OSError, SocketTimeout) as e: 975s self._raise_timeout( 975s err=e, url=self.proxy.url, timeout_value=conn.timeout 975s ) 975s raise 975s 975s # If we're going to release the connection in ``finally:``, then 975s # the response doesn't need to know about the connection. Otherwise 975s # it will also try to release it and we'll have a double-release 975s # mess. 975s response_conn = conn if not release_conn else None 975s 975s # Make the request on the HTTPConnection object 975s > response = self._make_request( 975s conn, 975s method, 975s url, 975s timeout=timeout_obj, 975s body=body, 975s headers=headers, 975s chunked=chunked, 975s retries=retries, 975s response_conn=response_conn, 975s preload_content=preload_content, 975s decode_content=decode_content, 975s **response_kw, 975s ) 975s 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 975s raise new_e 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 975s self._validate_conn(conn) 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 975s conn.connect() 975s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 975s self.sock = sock = self._new_conn() 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s 975s def _new_conn(self) -> socket.socket: 975s """Establish a socket connection and set nodelay settings on it. 975s 975s :return: New socket connection. 975s """ 975s try: 975s sock = connection.create_connection( 975s (self._dns_host, self.port), 975s self.timeout, 975s source_address=self.source_address, 975s socket_options=self.socket_options, 975s ) 975s except socket.gaierror as e: 975s raise NameResolutionError(self.host, self, e) from e 975s except SocketTimeout as e: 975s raise ConnectTimeoutError( 975s self, 975s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 975s ) from e 975s 975s except OSError as e: 975s > raise NewConnectionError( 975s self, f"Failed to establish a new connection: {e}" 975s ) from e 975s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 975s 975s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 975s 975s The above exception was the direct cause of the following exception: 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s > resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:667: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 975s retries = retries.increment( 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 975s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 975s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 975s _pool = 975s _stacktrace = 975s 975s def increment( 975s self, 975s method: str | None = None, 975s url: str | None = None, 975s response: BaseHTTPResponse | None = None, 975s error: Exception | None = None, 975s _pool: ConnectionPool | None = None, 975s _stacktrace: TracebackType | None = None, 975s ) -> Retry: 975s """Return a new Retry object with incremented retry counters. 975s 975s :param response: A response object, or None, if the server did not 975s return a response. 975s :type response: :class:`~urllib3.response.BaseHTTPResponse` 975s :param Exception error: An error encountered during the request, or 975s None if the response was received successfully. 975s 975s :return: A new ``Retry`` object. 975s """ 975s if self.total is False and error: 975s # Disabled, indicate to re-raise the error. 975s raise reraise(type(error), error, _stacktrace) 975s 975s total = self.total 975s if total is not None: 975s total -= 1 975s 975s connect = self.connect 975s read = self.read 975s redirect = self.redirect 975s status_count = self.status 975s other = self.other 975s cause = "unknown" 975s status = None 975s redirect_location = None 975s 975s if error and self._is_connection_error(error): 975s # Connect retry? 975s if connect is False: 975s raise reraise(type(error), error, _stacktrace) 975s elif connect is not None: 975s connect -= 1 975s 975s elif error and self._is_read_error(error): 975s # Read retry? 975s if read is False or method is None or not self._is_method_retryable(method): 975s raise reraise(type(error), error, _stacktrace) 975s elif read is not None: 975s read -= 1 975s 975s elif error: 975s # Other retry? 975s if other is not None: 975s other -= 1 975s 975s elif response and response.get_redirect_location(): 975s # Redirect retry? 975s if redirect is not None: 975s redirect -= 1 975s cause = "too many redirects" 975s response_redirect_location = response.get_redirect_location() 975s if response_redirect_location: 975s redirect_location = response_redirect_location 975s status = response.status 975s 975s else: 975s # Incrementing because of a server error like a 500 in 975s # status_forcelist and the given method is in the allowed_methods 975s cause = ResponseError.GENERIC_ERROR 975s if response and response.status: 975s if status_count is not None: 975s status_count -= 1 975s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 975s status = response.status 975s 975s history = self.history + ( 975s RequestHistory(method, url, error, status, redirect_location), 975s ) 975s 975s new_retry = self.new( 975s total=total, 975s connect=connect, 975s read=read, 975s redirect=redirect, 975s status=status_count, 975s other=other, 975s history=history, 975s ) 975s 975s if new_retry.is_exhausted(): 975s reason = error or ResponseError(cause) 975s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 975s E urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 975s 975s During handling of the above exception, another exception occurred: 975s 975s def test_encoding_for_model(): 975s > enc = tiktoken.encoding_for_model("gpt2") 975s 975s tests/test_simple_public.py:26: 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s /usr/lib/python3/dist-packages/tiktoken/model.py:105: in encoding_for_model 975s return get_encoding(encoding_name_for_model(model_name)) 975s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 975s enc = Encoding(**constructor()) 975s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 975s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 975s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 975s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 975s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 975s contents = read_file(blobpath) 975s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 975s resp = requests.get(blobpath) 975s /usr/lib/python3/dist-packages/requests/api.py:73: in get 975s return request("get", url, params=params, **kwargs) 975s /usr/lib/python3/dist-packages/requests/api.py:59: in request 975s return session.request(method=method, url=url, **kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 975s resp = self.send(prep, **send_kwargs) 975s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 975s r = adapter.send(request, **kwargs) 975s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 975s 975s self = 975s request = , stream = False 975s timeout = Timeout(connect=None, read=None, total=None), verify = True 975s cert = None, proxies = OrderedDict() 975s 975s def send( 975s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 975s ): 975s """Sends PreparedRequest object. Returns Response object. 975s 975s :param request: The :class:`PreparedRequest ` being sent. 975s :param stream: (optional) Whether to stream the request content. 975s :param timeout: (optional) How long to wait for the server to send 975s data before giving up, as a float, or a :ref:`(connect timeout, 975s read timeout) ` tuple. 975s :type timeout: float or tuple or urllib3 Timeout object 975s :param verify: (optional) Either a boolean, in which case it controls whether 975s we verify the server's TLS certificate, or a string, in which case it 975s must be a path to a CA bundle to use 975s :param cert: (optional) Any user-provided SSL certificate to be trusted. 975s :param proxies: (optional) The proxies dictionary to apply to the request. 975s :rtype: requests.Response 975s """ 975s 975s try: 975s conn = self.get_connection_with_tls_context( 975s request, verify, proxies=proxies, cert=cert 975s ) 975s except LocationValueError as e: 975s raise InvalidURL(e, request=request) 975s 975s self.cert_verify(conn, request.url, verify, cert) 975s url = self.request_url(request, proxies) 975s self.add_headers( 975s request, 975s stream=stream, 975s timeout=timeout, 975s verify=verify, 975s cert=cert, 975s proxies=proxies, 975s ) 975s 975s chunked = not (request.body is None or "Content-Length" in request.headers) 975s 975s if isinstance(timeout, tuple): 975s try: 975s connect, read = timeout 975s timeout = TimeoutSauce(connect=connect, read=read) 975s except ValueError: 975s raise ValueError( 975s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 975s f"or a single float to set both timeouts to the same value." 975s ) 975s elif isinstance(timeout, TimeoutSauce): 975s pass 975s else: 975s timeout = TimeoutSauce(connect=timeout, read=timeout) 975s 975s try: 975s resp = conn.urlopen( 975s method=request.method, 975s url=url, 975s body=request.body, 975s headers=request.headers, 975s redirect=False, 975s assert_same_host=False, 975s preload_content=False, 975s decode_content=False, 975s retries=self.max_retries, 975s timeout=timeout, 975s chunked=chunked, 975s ) 975s 975s except (ProtocolError, OSError) as err: 975s raise ConnectionError(err, request=request) 975s 975s except MaxRetryError as e: 975s if isinstance(e.reason, ConnectTimeoutError): 975s # TODO: Remove this in 3.0.0: see #2811 975s if not isinstance(e.reason, NewConnectionError): 975s raise ConnectTimeout(e, request=request) 975s 975s if isinstance(e.reason, ResponseError): 975s raise RetryError(e, request=request) 975s 975s if isinstance(e.reason, _ProxyError): 975s raise ProxyError(e, request=request) 975s 975s if isinstance(e.reason, _SSLError): 975s # This branch is for urllib3 v1.22 and later. 975s raise SSLError(e, request=request) 975s 975s > raise ConnectionError(e, request=request) 975s E requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openaipublic.blob.core.windows.net', port=443): Max retries exceeded with url: /gpt-2/encodings/main/vocab.bpe (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) 975s 975s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 975s =========================== short test summary info ============================ 975s FAILED tests/test_encoding.py::test_simple - requests.exceptions.ConnectionEr... 975s FAILED tests/test_encoding.py::test_simple_repeated - requests.exceptions.Con... 975s FAILED tests/test_encoding.py::test_simple_regex - requests.exceptions.Connec... 975s FAILED tests/test_encoding.py::test_basic_encode - requests.exceptions.Connec... 975s FAILED tests/test_encoding.py::test_encode_empty - requests.exceptions.Connec... 975s FAILED tests/test_encoding.py::test_encode_bytes - requests.exceptions.Connec... 975s FAILED tests/test_encoding.py::test_encode_surrogate_pairs - requests.excepti... 975s FAILED tests/test_encoding.py::test_catastrophically_repetitive[r50k_base] - ... 975s FAILED tests/test_encoding.py::test_catastrophically_repetitive[cl100k_base] 975s FAILED tests/test_encoding.py::test_basic_roundtrip[r50k_base] - requests.exc... 975s FAILED tests/test_encoding.py::test_basic_roundtrip[cl100k_base] - requests.e... 975s FAILED tests/test_encoding.py::test_hyp_roundtrip[r50k_base] - requests.excep... 975s FAILED tests/test_encoding.py::test_hyp_roundtrip[cl100k_base] - requests.exc... 975s FAILED tests/test_encoding.py::test_single_token_roundtrip[r50k_base] - reque... 975s FAILED tests/test_encoding.py::test_single_token_roundtrip[cl100k_base] - req... 975s FAILED tests/test_encoding.py::test_special_token - requests.exceptions.Conne... 975s FAILED tests/test_encoding.py::test_hyp_special_ordinary[r50k_base] - request... 975s FAILED tests/test_encoding.py::test_hyp_special_ordinary[cl100k_base] - reque... 975s FAILED tests/test_encoding.py::test_batch_encode[r50k_base] - requests.except... 975s FAILED tests/test_encoding.py::test_batch_encode[cl100k_base] - requests.exce... 975s FAILED tests/test_encoding.py::test_hyp_batch_roundtrip[r50k_base] - requests... 975s FAILED tests/test_encoding.py::test_hyp_batch_roundtrip[cl100k_base] - reques... 975s FAILED tests/test_misc.py::test_encoding_for_model - requests.exceptions.Conn... 975s FAILED tests/test_offsets.py::test_hyp_offsets[cl100k_base] - requests.except... 975s FAILED tests/test_offsets.py::test_basic_offsets - requests.exceptions.Connec... 975s FAILED tests/test_pickle.py::test_pickle - requests.exceptions.ConnectionErro... 975s FAILED tests/test_simple_public.py::test_simple - requests.exceptions.Connect... 975s FAILED tests/test_simple_public.py::test_encoding_for_model - requests.except... 975s ======================== 28 failed, 2 passed in 34.24s ========================= 976s autopkgtest [21:53:32]: test pybuild-autopkgtest: -----------------------] 976s pybuild-autopkgtest FAIL non-zero exit status 25 976s autopkgtest [21:53:32]: test pybuild-autopkgtest: - - - - - - - - - - results - - - - - - - - - - 977s autopkgtest [21:53:33]: @@@@@@@@@@@@@@@@@@@@ summary 977s pybuild-autopkgtest FAIL non-zero exit status 25 1598s nova [W] Using flock in prodstack6-s390x 1598s Creating nova instance adt-plucky-s390x-tiktoken-20241202-213716-juju-7f2275-prod-proposed-migration-environment-20-2348e5b9-3fca-4792-9cab-f91fef646b3c from image adt/ubuntu-plucky-s390x-server-20241202.img (UUID e0f6319f-b2f9-46f6-b34c-027899efb2c5)...