0s autopkgtest [20:30:59]: starting date and time: 2024-11-23 20:30:59+0000 0s autopkgtest [20:30:59]: git checkout: 0acbae0a WIP show VirtSubproc stderr in real-time 0s autopkgtest [20:30:59]: host juju-7f2275-prod-proposed-migration-environment-2; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.plg4mgh7/out --timeout-copy=6000 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:tiktoken,src:python3-defaults --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' -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor builder-cpu2-ram4-disk20 --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-2@bos03-30.secgroup --name adt-plucky-amd64-tiktoken-20241123-203058-juju-7f2275-prod-proposed-migration-environment-2-098cac6c-a9a9-4701-963a-30a2bc760522 --image adt/ubuntu-plucky-amd64-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-2 --net-id=net_prod-proposed-migration-amd64 -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/ 43s autopkgtest [20:31:42]: testbed dpkg architecture: amd64 43s autopkgtest [20:31:42]: testbed apt version: 2.9.8 43s autopkgtest [20:31:42]: @@@@@@@@@@@@@@@@@@@@ test bed setup 44s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed InRelease [73.9 kB] 44s Get:2 http://ftpmaster.internal/ubuntu plucky-proposed/universe Sources [930 kB] 44s Get:3 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse Sources [13.6 kB] 44s Get:4 http://ftpmaster.internal/ubuntu plucky-proposed/restricted Sources [9704 B] 44s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/main Sources [54.8 kB] 44s Get:6 http://ftpmaster.internal/ubuntu plucky-proposed/main i386 Packages [43.4 kB] 44s Get:7 http://ftpmaster.internal/ubuntu plucky-proposed/main amd64 Packages [91.3 kB] 44s Get:8 http://ftpmaster.internal/ubuntu plucky-proposed/restricted i386 Packages [2408 B] 44s Get:9 http://ftpmaster.internal/ubuntu plucky-proposed/restricted amd64 Packages [40.1 kB] 44s Get:10 http://ftpmaster.internal/ubuntu plucky-proposed/universe amd64 Packages [806 kB] 45s Get:11 http://ftpmaster.internal/ubuntu plucky-proposed/universe i386 Packages [295 kB] 45s Get:12 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse amd64 Packages [20.0 kB] 45s Get:13 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse i386 Packages [5528 B] 45s Fetched 2386 kB in 1s (2880 kB/s) 45s Reading package lists... 47s Reading package lists... 47s Building dependency tree... 47s Reading state information... 47s Calculating upgrade... 47s The following package was automatically installed and is no longer required: 47s libsgutils2-1.46-2 47s Use 'sudo apt autoremove' to remove it. 47s The following NEW packages will be installed: 47s libsgutils2-1.48 47s The following packages will be upgraded: 47s amd64-microcode bash bpftrace curl debconf debconf-i18n distro-info 47s fwupd-signed gir1.2-girepository-2.0 gir1.2-glib-2.0 hostname 47s intel-microcode libaudit-common libaudit1 libcurl3t64-gnutls libcurl4t64 47s libgirepository-1.0-1 libglib2.0-0t64 libglib2.0-data libpam-modules 47s libpam-modules-bin libpam-runtime libpam0g libplymouth5 libpython3-stdlib 47s libselinux1 libsemanage-common libsemanage2 linux-base lxd-installer 47s openssh-client openssh-server openssh-sftp-server plymouth 47s plymouth-theme-ubuntu-text python3 python3-blinker python3-dbus 47s python3-debconf python3-gi python3-jsonschema-specifications python3-minimal 47s python3-rpds-py python3-yaml sg3-utils sg3-utils-udev vim-common vim-tiny 47s xxd 48s 49 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. 48s Need to get 19.9 MB of archives. 48s After this operation, 4441 kB of additional disk space will be used. 48s Get:1 http://ftpmaster.internal/ubuntu plucky/main amd64 bash amd64 5.2.32-1ubuntu2 [918 kB] 48s Get:2 http://ftpmaster.internal/ubuntu plucky/main amd64 hostname amd64 3.25 [11.1 kB] 48s Get:3 http://ftpmaster.internal/ubuntu plucky/main amd64 libaudit-common all 1:4.0.2-2ubuntu1 [6578 B] 48s Get:4 http://ftpmaster.internal/ubuntu plucky/main amd64 libaudit1 amd64 1:4.0.2-2ubuntu1 [53.9 kB] 48s Get:5 http://ftpmaster.internal/ubuntu plucky/main amd64 debconf-i18n all 1.5.87ubuntu1 [204 kB] 48s Get:6 http://ftpmaster.internal/ubuntu plucky-proposed/main amd64 python3-minimal amd64 3.12.7-1 [27.4 kB] 48s Get:7 http://ftpmaster.internal/ubuntu plucky-proposed/main amd64 python3 amd64 3.12.7-1 [24.0 kB] 48s Get:8 http://ftpmaster.internal/ubuntu plucky-proposed/main amd64 libpython3-stdlib amd64 3.12.7-1 [10.0 kB] 48s Get:9 http://ftpmaster.internal/ubuntu plucky/main amd64 python3-debconf all 1.5.87ubuntu1 [4156 B] 48s Get:10 http://ftpmaster.internal/ubuntu plucky/main amd64 debconf all 1.5.87ubuntu1 [124 kB] 48s Get:11 http://ftpmaster.internal/ubuntu plucky/main amd64 libpam0g amd64 1.5.3-7ubuntu4 [69.6 kB] 48s Get:12 http://ftpmaster.internal/ubuntu plucky/main amd64 libselinux1 amd64 3.7-3ubuntu1 [86.9 kB] 48s Get:13 http://ftpmaster.internal/ubuntu plucky/main amd64 libpam-modules-bin amd64 1.5.3-7ubuntu4 [53.7 kB] 48s Get:14 http://ftpmaster.internal/ubuntu plucky/main amd64 libpam-modules amd64 1.5.3-7ubuntu4 [294 kB] 48s Get:15 http://ftpmaster.internal/ubuntu plucky/main amd64 openssh-sftp-server amd64 1:9.9p1-3ubuntu2 [41.2 kB] 48s Get:16 http://ftpmaster.internal/ubuntu plucky/main amd64 openssh-server amd64 1:9.9p1-3ubuntu2 [625 kB] 48s Get:17 http://ftpmaster.internal/ubuntu plucky/main amd64 openssh-client amd64 1:9.9p1-3ubuntu2 [1080 kB] 48s Get:18 http://ftpmaster.internal/ubuntu plucky/main amd64 libpam-runtime all 1.5.3-7ubuntu4 [40.8 kB] 48s Get:19 http://ftpmaster.internal/ubuntu plucky/main amd64 libsemanage-common all 3.7-2build1 [7186 B] 48s Get:20 http://ftpmaster.internal/ubuntu plucky/main amd64 libsemanage2 amd64 3.7-2build1 [105 kB] 48s Get:21 http://ftpmaster.internal/ubuntu plucky/main amd64 distro-info amd64 1.12 [20.0 kB] 48s Get:22 http://ftpmaster.internal/ubuntu plucky/main amd64 gir1.2-girepository-2.0 amd64 1.82.0-2 [25.3 kB] 48s Get:23 http://ftpmaster.internal/ubuntu plucky/main amd64 gir1.2-glib-2.0 amd64 2.82.2-3 [182 kB] 48s Get:24 http://ftpmaster.internal/ubuntu plucky/main amd64 libglib2.0-0t64 amd64 2.82.2-3 [1655 kB] 48s Get:25 http://ftpmaster.internal/ubuntu plucky/main amd64 libgirepository-1.0-1 amd64 1.82.0-2 [88.7 kB] 48s Get:26 http://ftpmaster.internal/ubuntu plucky/main amd64 libglib2.0-data all 2.82.2-3 [51.7 kB] 48s Get:27 http://ftpmaster.internal/ubuntu plucky/main amd64 python3-dbus amd64 1.3.2-5build4 [110 kB] 48s Get:28 http://ftpmaster.internal/ubuntu plucky/main amd64 python3-gi amd64 3.50.0-3build1 [293 kB] 48s Get:29 http://ftpmaster.internal/ubuntu plucky/main amd64 python3-yaml amd64 6.0.2-1build1 [187 kB] 48s Get:30 http://ftpmaster.internal/ubuntu plucky/main amd64 vim-tiny amd64 2:9.1.0861-1ubuntu1 [1037 kB] 48s Get:31 http://ftpmaster.internal/ubuntu plucky/main amd64 vim-common all 2:9.1.0861-1ubuntu1 [395 kB] 48s Get:32 http://ftpmaster.internal/ubuntu plucky/main amd64 xxd amd64 2:9.1.0861-1ubuntu1 [67.8 kB] 48s Get:33 http://ftpmaster.internal/ubuntu plucky/main amd64 libplymouth5 amd64 24.004.60-2ubuntu3 [145 kB] 48s Get:34 http://ftpmaster.internal/ubuntu plucky/main amd64 plymouth-theme-ubuntu-text amd64 24.004.60-2ubuntu3 [10.3 kB] 48s Get:35 http://ftpmaster.internal/ubuntu plucky/main amd64 plymouth amd64 24.004.60-2ubuntu3 [140 kB] 48s Get:36 http://ftpmaster.internal/ubuntu plucky/main amd64 bpftrace amd64 0.21.2-2ubuntu3 [1787 kB] 49s Get:37 http://ftpmaster.internal/ubuntu plucky/main amd64 curl amd64 8.9.1-2ubuntu3 [243 kB] 49s Get:38 http://ftpmaster.internal/ubuntu plucky/main amd64 libcurl4t64 amd64 8.9.1-2ubuntu3 [420 kB] 49s Get:39 http://ftpmaster.internal/ubuntu plucky/main amd64 fwupd-signed amd64 1.55+1.7-1 [30.6 kB] 49s Get:40 http://ftpmaster.internal/ubuntu plucky/main amd64 libcurl3t64-gnutls amd64 8.9.1-2ubuntu3 [412 kB] 49s Get:41 http://ftpmaster.internal/ubuntu plucky/main amd64 libsgutils2-1.48 amd64 1.48-0ubuntu1 [124 kB] 49s Get:42 http://ftpmaster.internal/ubuntu plucky/main amd64 linux-base all 4.10.1ubuntu1 [34.8 kB] 49s Get:43 http://ftpmaster.internal/ubuntu plucky/main amd64 lxd-installer all 10 [5264 B] 49s Get:44 http://ftpmaster.internal/ubuntu plucky/main amd64 python3-blinker all 1.9.0-1 [10.7 kB] 49s Get:45 http://ftpmaster.internal/ubuntu plucky/main amd64 python3-rpds-py amd64 0.21.0-2ubuntu1 [323 kB] 49s Get:46 http://ftpmaster.internal/ubuntu plucky/main amd64 python3-jsonschema-specifications all 2023.12.1-2 [9116 B] 49s Get:47 http://ftpmaster.internal/ubuntu plucky/main amd64 sg3-utils amd64 1.48-0ubuntu1 [1042 kB] 49s Get:48 http://ftpmaster.internal/ubuntu plucky/main amd64 sg3-utils-udev all 1.48-0ubuntu1 [6608 B] 49s Get:49 http://ftpmaster.internal/ubuntu plucky/main amd64 amd64-microcode amd64 3.20240820.1ubuntu1 [187 kB] 49s Get:50 http://ftpmaster.internal/ubuntu plucky/main amd64 intel-microcode amd64 3.20241112.1ubuntu2 [7055 kB] 49s Preconfiguring packages ... 49s Fetched 19.9 MB in 2s (13.2 MB/s) 49s (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 ... 75620 files and directories currently installed.) 49s Preparing to unpack .../bash_5.2.32-1ubuntu2_amd64.deb ... 50s Unpacking bash (5.2.32-1ubuntu2) over (5.2.32-1ubuntu1) ... 50s Setting up bash (5.2.32-1ubuntu2) ... 50s update-alternatives: using /usr/share/man/man7/bash-builtins.7.gz to provide /usr/share/man/man7/builtins.7.gz (builtins.7.gz) in auto mode 50s (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 ... 75620 files and directories currently installed.) 50s Preparing to unpack .../hostname_3.25_amd64.deb ... 50s Unpacking hostname (3.25) over (3.23+nmu2ubuntu2) ... 50s Setting up hostname (3.25) ... 50s (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 ... 75620 files and directories currently installed.) 50s Preparing to unpack .../libaudit-common_1%3a4.0.2-2ubuntu1_all.deb ... 50s Unpacking libaudit-common (1:4.0.2-2ubuntu1) over (1:4.0.1-1ubuntu2) ... 50s Setting up libaudit-common (1:4.0.2-2ubuntu1) ... 50s (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 ... 75620 files and directories currently installed.) 50s Preparing to unpack .../libaudit1_1%3a4.0.2-2ubuntu1_amd64.deb ... 50s Unpacking libaudit1:amd64 (1:4.0.2-2ubuntu1) over (1:4.0.1-1ubuntu2) ... 50s Setting up libaudit1:amd64 (1:4.0.2-2ubuntu1) ... 50s (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 ... 75620 files and directories currently installed.) 50s Preparing to unpack .../debconf-i18n_1.5.87ubuntu1_all.deb ... 50s Unpacking debconf-i18n (1.5.87ubuntu1) over (1.5.86ubuntu1) ... 50s Preparing to unpack .../python3-minimal_3.12.7-1_amd64.deb ... 50s Unpacking python3-minimal (3.12.7-1) over (3.12.6-0ubuntu1) ... 50s Setting up python3-minimal (3.12.7-1) ... 50s (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 ... 75620 files and directories currently installed.) 50s Preparing to unpack .../python3_3.12.7-1_amd64.deb ... 50s Unpacking python3 (3.12.7-1) over (3.12.6-0ubuntu1) ... 50s Preparing to unpack .../libpython3-stdlib_3.12.7-1_amd64.deb ... 50s Unpacking libpython3-stdlib:amd64 (3.12.7-1) over (3.12.6-0ubuntu1) ... 50s Preparing to unpack .../python3-debconf_1.5.87ubuntu1_all.deb ... 50s Unpacking python3-debconf (1.5.87ubuntu1) over (1.5.86ubuntu1) ... 50s Preparing to unpack .../debconf_1.5.87ubuntu1_all.deb ... 50s Unpacking debconf (1.5.87ubuntu1) over (1.5.86ubuntu1) ... 50s Setting up debconf (1.5.87ubuntu1) ... 50s (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 ... 75620 files and directories currently installed.) 50s Preparing to unpack .../libpam0g_1.5.3-7ubuntu4_amd64.deb ... 50s Unpacking libpam0g:amd64 (1.5.3-7ubuntu4) over (1.5.3-7ubuntu2) ... 50s Setting up libpam0g:amd64 (1.5.3-7ubuntu4) ... 51s (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 ... 75620 files and directories currently installed.) 51s Preparing to unpack .../libselinux1_3.7-3ubuntu1_amd64.deb ... 51s Unpacking libselinux1:amd64 (3.7-3ubuntu1) over (3.5-2ubuntu5) ... 51s Setting up libselinux1:amd64 (3.7-3ubuntu1) ... 51s (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 ... 75620 files and directories currently installed.) 51s Preparing to unpack .../libpam-modules-bin_1.5.3-7ubuntu4_amd64.deb ... 51s Unpacking libpam-modules-bin (1.5.3-7ubuntu4) over (1.5.3-7ubuntu2) ... 51s Setting up libpam-modules-bin (1.5.3-7ubuntu4) ... 51s pam_namespace.service is a disabled or a static unit not running, not starting it. 51s (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 ... 75620 files and directories currently installed.) 51s Preparing to unpack .../libpam-modules_1.5.3-7ubuntu4_amd64.deb ... 51s Unpacking libpam-modules:amd64 (1.5.3-7ubuntu4) over (1.5.3-7ubuntu2) ... 51s Setting up libpam-modules:amd64 (1.5.3-7ubuntu4) ... 51s (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 ... 75620 files and directories currently installed.) 51s Preparing to unpack .../openssh-sftp-server_1%3a9.9p1-3ubuntu2_amd64.deb ... 51s Unpacking openssh-sftp-server (1:9.9p1-3ubuntu2) over (1:9.7p1-7ubuntu5) ... 51s Preparing to unpack .../openssh-server_1%3a9.9p1-3ubuntu2_amd64.deb ... 51s Unpacking openssh-server (1:9.9p1-3ubuntu2) over (1:9.7p1-7ubuntu5) ... 51s Preparing to unpack .../openssh-client_1%3a9.9p1-3ubuntu2_amd64.deb ... 51s Unpacking openssh-client (1:9.9p1-3ubuntu2) over (1:9.7p1-7ubuntu5) ... 51s Preparing to unpack .../libpam-runtime_1.5.3-7ubuntu4_all.deb ... 51s Unpacking libpam-runtime (1.5.3-7ubuntu4) over (1.5.3-7ubuntu2) ... 51s Setting up libpam-runtime (1.5.3-7ubuntu4) ... 52s (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 ... 75622 files and directories currently installed.) 52s Preparing to unpack .../libsemanage-common_3.7-2build1_all.deb ... 52s Unpacking libsemanage-common (3.7-2build1) over (3.5-1build6) ... 52s Setting up libsemanage-common (3.7-2build1) ... 52s (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 ... 75621 files and directories currently installed.) 52s Preparing to unpack .../libsemanage2_3.7-2build1_amd64.deb ... 52s Unpacking libsemanage2:amd64 (3.7-2build1) over (3.5-1build6) ... 52s Setting up libsemanage2:amd64 (3.7-2build1) ... 52s (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 ... 75621 files and directories currently installed.) 52s Preparing to unpack .../00-distro-info_1.12_amd64.deb ... 52s Unpacking distro-info (1.12) over (1.9) ... 52s Preparing to unpack .../01-gir1.2-girepository-2.0_1.82.0-2_amd64.deb ... 52s Unpacking gir1.2-girepository-2.0:amd64 (1.82.0-2) over (1.80.1-4) ... 52s Preparing to unpack .../02-gir1.2-glib-2.0_2.82.2-3_amd64.deb ... 52s Unpacking gir1.2-glib-2.0:amd64 (2.82.2-3) over (2.82.1-0ubuntu1) ... 52s Preparing to unpack .../03-libglib2.0-0t64_2.82.2-3_amd64.deb ... 52s Unpacking libglib2.0-0t64:amd64 (2.82.2-3) over (2.82.1-0ubuntu1) ... 52s Preparing to unpack .../04-libgirepository-1.0-1_1.82.0-2_amd64.deb ... 52s Unpacking libgirepository-1.0-1:amd64 (1.82.0-2) over (1.80.1-4) ... 52s Preparing to unpack .../05-libglib2.0-data_2.82.2-3_all.deb ... 52s Unpacking libglib2.0-data (2.82.2-3) over (2.82.1-0ubuntu1) ... 52s Preparing to unpack .../06-python3-dbus_1.3.2-5build4_amd64.deb ... 52s Unpacking python3-dbus (1.3.2-5build4) over (1.3.2-5build3) ... 52s Preparing to unpack .../07-python3-gi_3.50.0-3build1_amd64.deb ... 52s Unpacking python3-gi (3.50.0-3build1) over (3.50.0-3) ... 52s Preparing to unpack .../08-python3-yaml_6.0.2-1build1_amd64.deb ... 52s Unpacking python3-yaml (6.0.2-1build1) over (6.0.2-1) ... 52s Preparing to unpack .../09-vim-tiny_2%3a9.1.0861-1ubuntu1_amd64.deb ... 52s Unpacking vim-tiny (2:9.1.0861-1ubuntu1) over (2:9.1.0777-1ubuntu1) ... 52s Preparing to unpack .../10-vim-common_2%3a9.1.0861-1ubuntu1_all.deb ... 52s Unpacking vim-common (2:9.1.0861-1ubuntu1) over (2:9.1.0777-1ubuntu1) ... 52s Preparing to unpack .../11-xxd_2%3a9.1.0861-1ubuntu1_amd64.deb ... 52s Unpacking xxd (2:9.1.0861-1ubuntu1) over (2:9.1.0777-1ubuntu1) ... 52s Preparing to unpack .../12-libplymouth5_24.004.60-2ubuntu3_amd64.deb ... 52s Unpacking libplymouth5:amd64 (24.004.60-2ubuntu3) over (24.004.60-1ubuntu11) ... 52s Preparing to unpack .../13-plymouth-theme-ubuntu-text_24.004.60-2ubuntu3_amd64.deb ... 52s Unpacking plymouth-theme-ubuntu-text (24.004.60-2ubuntu3) over (24.004.60-1ubuntu11) ... 52s Preparing to unpack .../14-plymouth_24.004.60-2ubuntu3_amd64.deb ... 52s Unpacking plymouth (24.004.60-2ubuntu3) over (24.004.60-1ubuntu11) ... 52s Preparing to unpack .../15-bpftrace_0.21.2-2ubuntu3_amd64.deb ... 52s Unpacking bpftrace (0.21.2-2ubuntu3) over (0.21.2-2ubuntu2) ... 52s Preparing to unpack .../16-curl_8.9.1-2ubuntu3_amd64.deb ... 52s Unpacking curl (8.9.1-2ubuntu3) over (8.9.1-2ubuntu2) ... 52s Preparing to unpack .../17-libcurl4t64_8.9.1-2ubuntu3_amd64.deb ... 52s Unpacking libcurl4t64:amd64 (8.9.1-2ubuntu3) over (8.9.1-2ubuntu2) ... 52s Preparing to unpack .../18-fwupd-signed_1.55+1.7-1_amd64.deb ... 52s Unpacking fwupd-signed (1.55+1.7-1) over (1.54+1.6-1build1) ... 52s Preparing to unpack .../19-libcurl3t64-gnutls_8.9.1-2ubuntu3_amd64.deb ... 52s Unpacking libcurl3t64-gnutls:amd64 (8.9.1-2ubuntu3) over (8.9.1-2ubuntu2) ... 52s Selecting previously unselected package libsgutils2-1.48:amd64. 52s Preparing to unpack .../20-libsgutils2-1.48_1.48-0ubuntu1_amd64.deb ... 52s Unpacking libsgutils2-1.48:amd64 (1.48-0ubuntu1) ... 52s Preparing to unpack .../21-linux-base_4.10.1ubuntu1_all.deb ... 52s Unpacking linux-base (4.10.1ubuntu1) over (4.5ubuntu9) ... 53s Preparing to unpack .../22-lxd-installer_10_all.deb ... 53s Unpacking lxd-installer (10) over (9) ... 53s Preparing to unpack .../23-python3-blinker_1.9.0-1_all.deb ... 53s Unpacking python3-blinker (1.9.0-1) over (1.8.2-1) ... 53s Preparing to unpack .../24-python3-rpds-py_0.21.0-2ubuntu1_amd64.deb ... 53s Unpacking python3-rpds-py (0.21.0-2ubuntu1) over (0.20.0-0ubuntu3) ... 53s Preparing to unpack .../25-python3-jsonschema-specifications_2023.12.1-2_all.deb ... 53s Unpacking python3-jsonschema-specifications (2023.12.1-2) over (2023.12.1-1ubuntu1) ... 53s Preparing to unpack .../26-sg3-utils_1.48-0ubuntu1_amd64.deb ... 53s Unpacking sg3-utils (1.48-0ubuntu1) over (1.46-3ubuntu5) ... 53s Preparing to unpack .../27-sg3-utils-udev_1.48-0ubuntu1_all.deb ... 53s Unpacking sg3-utils-udev (1.48-0ubuntu1) over (1.46-3ubuntu5) ... 53s Preparing to unpack .../28-amd64-microcode_3.20240820.1ubuntu1_amd64.deb ... 53s Unpacking amd64-microcode (3.20240820.1ubuntu1) over (3.20240116.2+nmu1ubuntu1.1) ... 53s Preparing to unpack .../29-intel-microcode_3.20241112.1ubuntu2_amd64.deb ... 53s Unpacking intel-microcode (3.20241112.1ubuntu2) over (3.20240910.0ubuntu1) ... 53s Setting up distro-info (1.12) ... 53s Setting up linux-base (4.10.1ubuntu1) ... 53s Setting up libcurl4t64:amd64 (8.9.1-2ubuntu3) ... 53s Setting up bpftrace (0.21.2-2ubuntu3) ... 53s Setting up openssh-client (1:9.9p1-3ubuntu2) ... 53s Setting up intel-microcode (3.20241112.1ubuntu2) ... 53s intel-microcode: microcode will be updated at next boot 53s Setting up libcurl3t64-gnutls:amd64 (8.9.1-2ubuntu3) ... 53s Setting up fwupd-signed (1.55+1.7-1) ... 53s Setting up libsgutils2-1.48:amd64 (1.48-0ubuntu1) ... 53s Setting up debconf-i18n (1.5.87ubuntu1) ... 53s Setting up amd64-microcode (3.20240820.1ubuntu1) ... 53s amd64-microcode: microcode will be updated at next boot 53s Setting up xxd (2:9.1.0861-1ubuntu1) ... 53s Setting up libglib2.0-0t64:amd64 (2.82.2-3) ... 53s No schema files found: doing nothing. 53s Setting up libglib2.0-data (2.82.2-3) ... 53s Setting up vim-common (2:9.1.0861-1ubuntu1) ... 53s Setting up gir1.2-glib-2.0:amd64 (2.82.2-3) ... 53s Setting up lxd-installer (10) ... 53s Setting up libplymouth5:amd64 (24.004.60-2ubuntu3) ... 53s Setting up libgirepository-1.0-1:amd64 (1.82.0-2) ... 53s Setting up curl (8.9.1-2ubuntu3) ... 53s Setting up libpython3-stdlib:amd64 (3.12.7-1) ... 53s Setting up sg3-utils (1.48-0ubuntu1) ... 53s Setting up openssh-sftp-server (1:9.9p1-3ubuntu2) ... 53s Setting up openssh-server (1:9.9p1-3ubuntu2) ... 53s Installing new version of config file /etc/ssh/moduli ... 54s Replacing config file /etc/ssh/sshd_config with new version 54s Setting up plymouth (24.004.60-2ubuntu3) ... 54s update-initramfs: Generating /boot/initrd.img-6.11.0-8-generic 54s W: No lz4 in /usr/bin:/sbin:/bin, using gzip 62s update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults 62s update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults 62s Setting up python3 (3.12.7-1) ... 62s Setting up vim-tiny (2:9.1.0861-1ubuntu1) ... 62s Setting up sg3-utils-udev (1.48-0ubuntu1) ... 62s update-initramfs: deferring update (trigger activated) 62s Setting up plymouth-theme-ubuntu-text (24.004.60-2ubuntu3) ... 62s update-initramfs: deferring update (trigger activated) 62s Setting up gir1.2-girepository-2.0:amd64 (1.82.0-2) ... 62s Setting up python3-gi (3.50.0-3build1) ... 63s Setting up python3-rpds-py (0.21.0-2ubuntu1) ... 63s Setting up python3-jsonschema-specifications (2023.12.1-2) ... 63s Setting up python3-blinker (1.9.0-1) ... 63s Setting up python3-dbus (1.3.2-5build4) ... 63s Setting up python3-debconf (1.5.87ubuntu1) ... 63s Setting up python3-yaml (6.0.2-1build1) ... 63s Processing triggers for man-db (2.13.0-1) ... 65s Processing triggers for debianutils (5.21) ... 65s Processing triggers for install-info (7.1.1-1) ... 65s Processing triggers for initramfs-tools (0.142ubuntu35) ... 65s update-initramfs: Generating /boot/initrd.img-6.11.0-8-generic 65s W: No lz4 in /usr/bin:/sbin:/bin, using gzip 71s Processing triggers for libc-bin (2.40-1ubuntu3) ... 71s Processing triggers for ufw (0.36.2-8) ... 71s Reading package lists... 72s Building dependency tree... 72s Reading state information... 72s The following packages will be REMOVED: 72s libsgutils2-1.46-2* 72s 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. 72s After this operation, 294 kB disk space will be freed. 72s (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 ... 75656 files and directories currently installed.) 72s Removing libsgutils2-1.46-2:amd64 (1.46-3ubuntu5) ... 72s Processing triggers for libc-bin (2.40-1ubuntu3) ... 73s Hit:1 http://ftpmaster.internal/ubuntu plucky-proposed InRelease 73s Hit:2 http://ftpmaster.internal/ubuntu plucky InRelease 73s Hit:3 http://ftpmaster.internal/ubuntu plucky-updates InRelease 73s Hit:4 http://ftpmaster.internal/ubuntu plucky-security InRelease 74s Reading package lists... 74s Reading package lists... 74s Building dependency tree... 74s Reading state information... 74s Calculating upgrade... 74s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 74s Reading package lists... 74s Building dependency tree... 74s Reading state information... 74s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 75s autopkgtest [20:32:14]: rebooting testbed after setup commands that affected boot 78s autopkgtest-virt-ssh: WARNING: ssh connection failed. Retrying in 3 seconds... 92s autopkgtest [20:32:31]: testbed running kernel: Linux 6.11.0-8-generic #8-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 16 13:41:20 UTC 2024 95s autopkgtest [20:32:34]: @@@@@@@@@@@@@@@@@@@@ apt-source tiktoken 97s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed/universe tiktoken 0.8.0-1build1 (dsc) [2247 B] 97s Get:2 http://ftpmaster.internal/ubuntu plucky-proposed/universe tiktoken 0.8.0-1build1 (tar) [31.6 kB] 97s Get:3 http://ftpmaster.internal/ubuntu plucky-proposed/universe tiktoken 0.8.0-1build1 (diff) [3908 B] 97s gpgv: Signature made Mon Nov 18 15:38:19 2024 UTC 97s gpgv: using RSA key 25E3FF2D7F469DBE7D0D4E50AFCFEC8E669CE1C2 97s gpgv: Can't check signature: No public key 97s dpkg-source: warning: cannot verify inline signature for ./tiktoken_0.8.0-1build1.dsc: no acceptable signature found 97s autopkgtest [20:32:36]: testing package tiktoken version 0.8.0-1build1 97s autopkgtest [20:32:36]: build not needed 98s autopkgtest [20:32:37]: test pybuild-autopkgtest: preparing testbed 99s Reading package lists... 99s Building dependency tree... 99s Reading state information... 99s Starting pkgProblemResolver with broken count: 0 99s Starting 2 pkgProblemResolver with broken count: 0 99s Done 99s The following additional packages will be installed: 99s autoconf automake autopoint autotools-dev binutils-mingw-w64-i686 99s binutils-mingw-w64-x86-64 build-essential cargo cargo-1.80 cmake cmake-data 99s cpp cpp-14 cpp-14-x86-64-linux-gnu cpp-x86-64-linux-gnu debhelper debugedit 99s dh-autoreconf dh-python dh-strip-nondeterminism dwz fontconfig-config 99s fonts-dejavu-core fonts-dejavu-mono g++ g++-14 g++-14-x86-64-linux-gnu 99s g++-x86-64-linux-gnu gcc gcc-14 gcc-14-x86-64-linux-gnu gcc-x86-64-linux-gnu 99s gettext intltool-debian libarchive-zip-perl libasan8 libbrotli-dev 99s libbz2-dev libcc1-0 libdebhelper-perl libexpat1-dev 99s libfile-stripnondeterminism-perl libfontconfig-dev libfontconfig1 99s libfreetype-dev libgcc-14-dev libgit2-1.7 libgomp1 libhttp-parser2.9 99s libhwasan0 libisl23 libitm1 libjsoncpp25 liblsan0 libmpc3 libpfm4 99s libpkgconf3 libpng-dev libpython3-all-dev libpython3-dev libpython3.12-dev 99s libpython3.13 libpython3.13-dev libpython3.13-minimal libpython3.13-stdlib 99s libquadmath0 librhash0 librust-ab-glyph-dev 99s librust-ab-glyph-rasterizer+libm-dev librust-ab-glyph-rasterizer-dev 99s librust-addr2line-dev librust-adler-dev librust-ahash-dev 99s librust-aho-corasick-dev librust-allocator-api2-dev librust-anes-dev 99s librust-anstream-dev librust-anstyle-dev librust-anstyle-parse-dev 99s librust-anstyle-query-dev librust-anyhow-dev librust-approx-dev 99s librust-arbitrary-dev librust-array-init-dev librust-arrayvec-dev 99s librust-async-attributes-dev librust-async-channel-dev 99s librust-async-executor-dev librust-async-fs-dev 99s librust-async-global-executor-dev librust-async-io-dev 99s librust-async-lock-dev librust-async-net-dev librust-async-process-dev 99s librust-async-signal-dev librust-async-std-dev librust-async-task-dev 99s librust-atomic-dev librust-atomic-waker-dev librust-autocfg-dev 99s librust-backtrace-dev librust-base64-dev librust-bit-set+std-dev 99s librust-bit-set-dev librust-bit-vec-dev librust-bitflags-1-dev 99s librust-bitflags-dev librust-bitvec-dev librust-blobby-dev 99s librust-block-buffer-dev librust-blocking-dev librust-bstr-dev 99s librust-bumpalo-dev librust-bytecheck-derive-dev librust-bytecheck-dev 99s librust-bytemuck-derive-dev librust-bytemuck-dev librust-byteorder-dev 99s librust-bytes-dev librust-cast-dev librust-cc-dev librust-cfg-if-0.1-dev 99s librust-cfg-if-dev librust-chrono-dev librust-chrono-tz-build-dev 99s librust-chrono-tz-dev librust-ciborium-dev librust-ciborium-io-dev 99s librust-ciborium-ll-dev librust-clap-builder-dev librust-clap-derive-dev 99s librust-clap-dev librust-clap-lex-dev librust-cmake-dev 99s librust-color-quant-dev librust-colorchoice-dev 99s librust-compiler-builtins+core-dev 99s librust-compiler-builtins+rustc-dep-of-std-dev librust-compiler-builtins-dev 99s librust-concurrent-queue-dev librust-const-cstr-dev librust-const-oid-dev 99s librust-const-random-dev librust-const-random-macro-dev 99s librust-convert-case-dev librust-core-maths-dev librust-cpp-demangle-dev 99s librust-cpufeatures-dev librust-crc32fast-dev librust-criterion-dev 99s librust-critical-section-dev librust-crossbeam-deque-dev 99s librust-crossbeam-epoch+std-dev librust-crossbeam-epoch-dev 99s librust-crossbeam-utils-dev librust-crunchy-dev librust-crypto-common-dev 99s librust-csv-core-dev librust-csv-dev librust-ctor-dev librust-deranged-dev 99s librust-derive-arbitrary-dev librust-derive-more-0.99-dev librust-digest-dev 99s librust-dirs-next-dev librust-dirs-sys-next-dev librust-dlib-dev 99s librust-either-dev librust-env-logger-dev librust-equivalent-dev 99s librust-erased-serde-dev librust-errno-dev librust-eui48-dev 99s librust-event-listener-dev librust-event-listener-strategy-dev 99s librust-eyre+default-dev librust-eyre-dev librust-fallible-iterator-dev 99s librust-fancy-regex-dev librust-fastrand-dev librust-flate2-dev 99s librust-float-ord-dev librust-fnv-dev librust-font-kit-dev 99s librust-freetype-dev librust-freetype-sys-dev librust-funty-dev 99s librust-futures-channel-dev librust-futures-core-dev librust-futures-dev 99s librust-futures-executor-dev librust-futures-io-dev librust-futures-lite-dev 99s librust-futures-macro-dev librust-futures-sink-dev librust-futures-task-dev 99s librust-futures-util-dev librust-generic-array-dev librust-geo-types-dev 99s librust-getrandom-dev librust-ghost-dev librust-gif-dev librust-gimli-dev 99s librust-half-dev librust-hashbrown-dev librust-heck-dev librust-hmac-dev 99s librust-humantime-dev librust-iana-time-zone-dev librust-image-dev 99s librust-indenter-dev librust-indexmap-dev librust-indoc-dev 99s librust-inventory-dev librust-is-terminal-dev librust-itertools-dev 99s librust-itoa-dev librust-jobserver-dev librust-jpeg-decoder-dev 99s librust-js-sys-dev librust-kv-log-macro-dev librust-lazy-static-dev 99s librust-libc-dev librust-libloading-dev librust-libm-dev 99s librust-libwebp-sys-dev librust-libz-sys-dev librust-linux-raw-sys-dev 99s librust-lock-api-dev librust-log-dev librust-md-5-dev librust-md5-asm-dev 99s librust-memchr-dev librust-memmap2-dev librust-memoffset-dev 99s librust-miniz-oxide-dev librust-mio-dev librust-no-panic-dev 99s librust-num-bigint-dev librust-num-complex-dev librust-num-conv-dev 99s librust-num-cpus-dev librust-num-integer-dev librust-num-rational-dev 99s librust-num-threads-dev librust-num-traits-dev librust-object-dev 99s librust-once-cell-dev librust-oorandom-dev librust-owned-ttf-parser-dev 99s librust-owning-ref-dev librust-parking-dev librust-parking-lot-core-dev 99s librust-parking-lot-dev librust-parse-zoneinfo-dev 99s librust-pathfinder-geometry-dev librust-pathfinder-simd-dev 99s librust-phf+uncased-dev librust-phf-codegen-dev librust-phf-dev 99s librust-phf-generator-dev librust-phf-shared+uncased-dev 99s librust-phf-shared-dev librust-pin-project-lite-dev librust-pin-utils-dev 99s librust-pkg-config-dev librust-plotters-backend-dev 99s librust-plotters-bitmap-dev librust-plotters-dev librust-plotters-svg-dev 99s librust-png-dev librust-polling-dev librust-portable-atomic-dev 99s librust-postgres-derive-dev librust-postgres-protocol-dev 99s librust-postgres-types-dev librust-powerfmt-dev librust-powerfmt-macros-dev 99s librust-ppv-lite86-dev librust-proc-macro2-dev librust-proptest-dev 99s librust-ptr-meta-derive-dev librust-ptr-meta-dev 99s librust-pure-rust-locales-dev librust-pyo3-build-config-dev librust-pyo3-dev 99s librust-pyo3-ffi-dev librust-pyo3-macros-backend-dev librust-pyo3-macros-dev 99s librust-python3-dll-a-dev librust-qoi-dev librust-quick-error-dev 99s librust-quickcheck-dev librust-quote-dev librust-radium-dev 99s librust-rand-chacha-dev librust-rand-core+getrandom-dev 99s librust-rand-core+serde-dev librust-rand-core+std-dev librust-rand-core-dev 99s librust-rand-dev librust-rand-xorshift-dev librust-rayon-core-dev 99s librust-rayon-dev librust-regex-automata-dev librust-regex-dev 99s librust-regex-syntax-dev librust-rend-dev librust-rkyv-derive-dev 99s librust-rkyv-dev librust-rust-decimal-dev librust-rustc-demangle-dev 99s librust-rustc-hash-dev librust-rustc-std-workspace-core-dev 99s librust-rustc-version-dev librust-rustix-dev 99s librust-rusty-fork+wait-timeout-dev librust-rusty-fork-dev 99s librust-ruzstd-dev librust-ryu-dev librust-same-file-dev 99s librust-scopeguard-dev librust-seahash-dev librust-semver-dev 99s librust-serde-derive-dev librust-serde-dev librust-serde-fmt-dev 99s librust-serde-json-dev librust-serde-test-dev librust-sha1-asm-dev 99s librust-sha1-dev librust-sha2-asm-dev librust-sha2-dev librust-shlex-dev 99s librust-signal-hook-registry-dev librust-simdutf8-dev librust-siphasher-dev 99s librust-slab-dev librust-slog-dev librust-smallvec-dev librust-smol-dev 99s librust-smol-str-dev librust-socket2-dev librust-spin-dev 99s librust-stable-deref-trait-dev librust-static-assertions-dev 99s librust-stringprep-dev librust-strsim-dev librust-subtle-dev 99s librust-sval-buffer-dev librust-sval-derive-dev librust-sval-dev 99s librust-sval-dynamic-dev librust-sval-fmt-dev librust-sval-ref-dev 99s librust-sval-serde-dev librust-syn-1-dev librust-syn-dev librust-tap-dev 99s librust-target-lexicon-dev librust-tempfile-dev librust-termcolor-dev 99s librust-terminal-size-dev librust-tiff-dev librust-time-core-dev 99s librust-time-dev librust-time-macros-dev librust-tiny-keccak-dev 99s librust-tinytemplate-dev librust-tinyvec+tinyvec-macros-dev 99s librust-tinyvec-dev librust-tinyvec-macros-dev librust-tokio-dev 99s librust-tokio-macros-dev librust-tracing-attributes-dev 99s librust-tracing-core-dev librust-tracing-dev librust-traitobject-dev 99s librust-ttf-parser-dev librust-twox-hash-dev librust-typemap-dev 99s librust-typenum-dev librust-unarray-dev librust-uncased-dev 99s librust-unicase-dev librust-unicode-bidi-dev librust-unicode-ident-dev 99s librust-unicode-normalization-dev librust-unicode-segmentation-dev 99s librust-unicode-width-dev librust-unindent-dev librust-unsafe-any-dev 99s librust-utf8parse-dev librust-uuid-dev librust-valuable-derive-dev 99s librust-valuable-dev librust-value-bag-dev librust-value-bag-serde1-dev 99s librust-value-bag-sval2-dev librust-version-check-dev 99s librust-wait-timeout-dev librust-walkdir-dev 99s librust-wasm-bindgen+default-dev librust-wasm-bindgen+spans-dev 99s librust-wasm-bindgen-backend-dev librust-wasm-bindgen-dev 99s librust-wasm-bindgen-macro+spans-dev librust-wasm-bindgen-macro-dev 99s librust-wasm-bindgen-macro-support+spans-dev 99s librust-wasm-bindgen-macro-support-dev librust-wasm-bindgen-shared-dev 99s librust-web-sys-dev librust-webp-dev librust-weezl-dev librust-winapi-dev 99s librust-winapi-i686-pc-windows-gnu-dev librust-winapi-util-dev 99s librust-winapi-x86-64-pc-windows-gnu-dev librust-wyz-dev 99s librust-yeslogic-fontconfig-sys-dev librust-zerocopy-derive-dev 99s librust-zerocopy-dev librust-zeroize-derive-dev librust-zeroize-dev 99s libsharpyuv-dev libsharpyuv0 libstd-rust-1.80 libstd-rust-1.80-dev 99s libstdc++-14-dev libtool libtsan2 libubsan1 libwebp-dev libwebp7 99s libwebpdecoder3 libwebpdemux2 libwebpmux3 llvm llvm-19 llvm-19-linker-tools 99s llvm-19-runtime llvm-runtime m4 pkg-config pkgconf pkgconf-bin po-debconf 99s pybuild-plugin-autopkgtest pybuild-plugin-pyproject python3-all 99s python3-build python3-dateutil python3-hypothesis python3-iniconfig 99s python3-installer python3-packaging python3-pluggy python3-pyproject-hooks 99s python3-pytest python3-regex python3-semantic-version 99s python3-setuptools-rust python3-sortedcontainers python3-tiktoken 99s python3-toml python3-wheel python3.12-dev python3.13 python3.13-minimal 99s rustc rustc-1.80 uuid-dev zlib1g-dev 99s Suggested packages: 99s autoconf-archive gnu-standards autoconf-doc cargo-1.80-doc cmake-doc 99s cmake-format elpa-cmake-mode ninja-build cpp-doc gcc-14-locales cpp-14-doc 99s dh-make flit g++-multilib g++-14-multilib gcc-14-doc gcc-multilib 99s manpages-dev flex bison gdb gcc-doc gcc-14-multilib gdb-x86-64-linux-gnu 99s gettext-doc libasprintf-dev libgettextpo-dev freetype2-doc 99s librust-adler+compiler-builtins-dev librust-adler+core-dev 99s librust-adler+rustc-dep-of-std-dev librust-backtrace+cpp-demangle-dev 99s librust-backtrace+rustc-serialize-dev librust-backtrace+serde-dev 99s librust-backtrace+verify-winapi-dev librust-backtrace+winapi-dev 99s librust-cfg-if-0.1+core-dev librust-cfg-if+core-dev 99s librust-compiler-builtins+c-dev gnuplot-nox librust-csv-core+libc-dev 99s librust-either+serde-dev librust-getrandom+compiler-builtins-dev 99s librust-getrandom+core-dev librust-getrandom+rustc-dep-of-std-dev 99s librust-libc+rustc-dep-of-std-dev librust-libc+rustc-std-workspace-core-dev 99s librust-phf+phf-macros-dev librust-phf+serde-dev librust-phf+unicase-dev 99s librust-phf-shared+unicase-dev librust-rand-xorshift+serde-dev 99s librust-rustc-demangle+compiler-builtins-dev librust-rustc-demangle+core-dev 99s librust-rustc-demangle+rustc-dep-of-std-dev librust-ryu+no-panic-dev 99s librust-slog+erased-serde-dev librust-tinyvec+arbitrary-dev 99s librust-tinyvec+serde-dev librust-uncased+serde-dev 99s librust-uncased+with-serde-alloc-dev 99s librust-wasm-bindgen-backend+extra-traits-dev librust-wasm-bindgen+serde-dev 99s librust-wasm-bindgen+serde-serialize-dev librust-wasm-bindgen+serde-json-dev 99s librust-wasm-bindgen+strict-macro-dev 99s librust-wasm-bindgen+xxx-debug-only-print-generated-code-dev 99s librust-wasm-bindgen-macro+strict-macro-dev 99s librust-wasm-bindgen-macro-support+extra-traits-dev librust-weezl+async-dev 99s librust-weezl+futures-dev libstdc++-14-doc libtool-doc gfortran 99s | fortran95-compiler gcj-jdk llvm-19-doc m4-doc libmail-box-perl python3-pip 99s python3-venv python-build-doc python-hypothesis-doc python-installer-doc 99s python-semantic-version-doc python-sortedcontainers-doc python3.13-venv 99s python3.13-doc binfmt-support llvm-18 lld-18 clang-18 99s Recommended packages: 99s bzip2-doc libarchive-cpio-perl libpng-tools librust-phf+std-dev 99s librust-subtle+default-dev libltdl-dev llvm-19-dev libmail-sendmail-perl 99s python3-click 100s The following NEW packages will be installed: 100s autoconf automake autopkgtest-satdep autopoint autotools-dev 100s binutils-mingw-w64-i686 binutils-mingw-w64-x86-64 build-essential cargo 100s cargo-1.80 cmake cmake-data cpp cpp-14 cpp-14-x86-64-linux-gnu 100s cpp-x86-64-linux-gnu debhelper debugedit dh-autoreconf dh-python 100s dh-strip-nondeterminism dwz fontconfig-config fonts-dejavu-core 100s fonts-dejavu-mono g++ g++-14 g++-14-x86-64-linux-gnu g++-x86-64-linux-gnu 100s gcc gcc-14 gcc-14-x86-64-linux-gnu gcc-x86-64-linux-gnu gettext 100s intltool-debian libarchive-zip-perl libasan8 libbrotli-dev libbz2-dev 100s libcc1-0 libdebhelper-perl libexpat1-dev libfile-stripnondeterminism-perl 100s libfontconfig-dev libfontconfig1 libfreetype-dev libgcc-14-dev libgit2-1.7 100s libgomp1 libhttp-parser2.9 libhwasan0 libisl23 libitm1 libjsoncpp25 liblsan0 100s libmpc3 libpfm4 libpkgconf3 libpng-dev libpython3-all-dev libpython3-dev 100s libpython3.12-dev libpython3.13 libpython3.13-dev libpython3.13-minimal 100s libpython3.13-stdlib libquadmath0 librhash0 librust-ab-glyph-dev 100s librust-ab-glyph-rasterizer+libm-dev librust-ab-glyph-rasterizer-dev 100s librust-addr2line-dev librust-adler-dev librust-ahash-dev 100s librust-aho-corasick-dev librust-allocator-api2-dev librust-anes-dev 100s librust-anstream-dev librust-anstyle-dev librust-anstyle-parse-dev 100s librust-anstyle-query-dev librust-anyhow-dev librust-approx-dev 100s librust-arbitrary-dev librust-array-init-dev librust-arrayvec-dev 100s librust-async-attributes-dev librust-async-channel-dev 100s librust-async-executor-dev librust-async-fs-dev 100s librust-async-global-executor-dev librust-async-io-dev 100s librust-async-lock-dev librust-async-net-dev librust-async-process-dev 100s librust-async-signal-dev librust-async-std-dev librust-async-task-dev 100s librust-atomic-dev librust-atomic-waker-dev librust-autocfg-dev 100s librust-backtrace-dev librust-base64-dev librust-bit-set+std-dev 100s librust-bit-set-dev librust-bit-vec-dev librust-bitflags-1-dev 100s librust-bitflags-dev librust-bitvec-dev librust-blobby-dev 100s librust-block-buffer-dev librust-blocking-dev librust-bstr-dev 100s librust-bumpalo-dev librust-bytecheck-derive-dev librust-bytecheck-dev 100s librust-bytemuck-derive-dev librust-bytemuck-dev librust-byteorder-dev 100s librust-bytes-dev librust-cast-dev librust-cc-dev librust-cfg-if-0.1-dev 100s librust-cfg-if-dev librust-chrono-dev librust-chrono-tz-build-dev 100s librust-chrono-tz-dev librust-ciborium-dev librust-ciborium-io-dev 100s librust-ciborium-ll-dev librust-clap-builder-dev librust-clap-derive-dev 100s librust-clap-dev librust-clap-lex-dev librust-cmake-dev 100s librust-color-quant-dev librust-colorchoice-dev 100s librust-compiler-builtins+core-dev 100s librust-compiler-builtins+rustc-dep-of-std-dev librust-compiler-builtins-dev 100s librust-concurrent-queue-dev librust-const-cstr-dev librust-const-oid-dev 100s librust-const-random-dev librust-const-random-macro-dev 100s librust-convert-case-dev librust-core-maths-dev librust-cpp-demangle-dev 100s librust-cpufeatures-dev librust-crc32fast-dev librust-criterion-dev 100s librust-critical-section-dev librust-crossbeam-deque-dev 100s librust-crossbeam-epoch+std-dev librust-crossbeam-epoch-dev 100s librust-crossbeam-utils-dev librust-crunchy-dev librust-crypto-common-dev 100s librust-csv-core-dev librust-csv-dev librust-ctor-dev librust-deranged-dev 100s librust-derive-arbitrary-dev librust-derive-more-0.99-dev librust-digest-dev 100s librust-dirs-next-dev librust-dirs-sys-next-dev librust-dlib-dev 100s librust-either-dev librust-env-logger-dev librust-equivalent-dev 100s librust-erased-serde-dev librust-errno-dev librust-eui48-dev 100s librust-event-listener-dev librust-event-listener-strategy-dev 100s librust-eyre+default-dev librust-eyre-dev librust-fallible-iterator-dev 100s librust-fancy-regex-dev librust-fastrand-dev librust-flate2-dev 100s librust-float-ord-dev librust-fnv-dev librust-font-kit-dev 100s librust-freetype-dev librust-freetype-sys-dev librust-funty-dev 100s librust-futures-channel-dev librust-futures-core-dev librust-futures-dev 100s librust-futures-executor-dev librust-futures-io-dev librust-futures-lite-dev 100s librust-futures-macro-dev librust-futures-sink-dev librust-futures-task-dev 100s librust-futures-util-dev librust-generic-array-dev librust-geo-types-dev 100s librust-getrandom-dev librust-ghost-dev librust-gif-dev librust-gimli-dev 100s librust-half-dev librust-hashbrown-dev librust-heck-dev librust-hmac-dev 100s librust-humantime-dev librust-iana-time-zone-dev librust-image-dev 100s librust-indenter-dev librust-indexmap-dev librust-indoc-dev 100s librust-inventory-dev librust-is-terminal-dev librust-itertools-dev 100s librust-itoa-dev librust-jobserver-dev librust-jpeg-decoder-dev 100s librust-js-sys-dev librust-kv-log-macro-dev librust-lazy-static-dev 100s librust-libc-dev librust-libloading-dev librust-libm-dev 100s librust-libwebp-sys-dev librust-libz-sys-dev librust-linux-raw-sys-dev 100s librust-lock-api-dev librust-log-dev librust-md-5-dev librust-md5-asm-dev 100s librust-memchr-dev librust-memmap2-dev librust-memoffset-dev 100s librust-miniz-oxide-dev librust-mio-dev librust-no-panic-dev 100s librust-num-bigint-dev librust-num-complex-dev librust-num-conv-dev 100s librust-num-cpus-dev librust-num-integer-dev librust-num-rational-dev 100s librust-num-threads-dev librust-num-traits-dev librust-object-dev 100s librust-once-cell-dev librust-oorandom-dev librust-owned-ttf-parser-dev 100s librust-owning-ref-dev librust-parking-dev librust-parking-lot-core-dev 100s librust-parking-lot-dev librust-parse-zoneinfo-dev 100s librust-pathfinder-geometry-dev librust-pathfinder-simd-dev 100s librust-phf+uncased-dev librust-phf-codegen-dev librust-phf-dev 100s librust-phf-generator-dev librust-phf-shared+uncased-dev 100s librust-phf-shared-dev librust-pin-project-lite-dev librust-pin-utils-dev 100s librust-pkg-config-dev librust-plotters-backend-dev 100s librust-plotters-bitmap-dev librust-plotters-dev librust-plotters-svg-dev 100s librust-png-dev librust-polling-dev librust-portable-atomic-dev 100s librust-postgres-derive-dev librust-postgres-protocol-dev 100s librust-postgres-types-dev librust-powerfmt-dev librust-powerfmt-macros-dev 100s librust-ppv-lite86-dev librust-proc-macro2-dev librust-proptest-dev 100s librust-ptr-meta-derive-dev librust-ptr-meta-dev 100s librust-pure-rust-locales-dev librust-pyo3-build-config-dev librust-pyo3-dev 100s librust-pyo3-ffi-dev librust-pyo3-macros-backend-dev librust-pyo3-macros-dev 100s librust-python3-dll-a-dev librust-qoi-dev librust-quick-error-dev 100s librust-quickcheck-dev librust-quote-dev librust-radium-dev 100s librust-rand-chacha-dev librust-rand-core+getrandom-dev 100s librust-rand-core+serde-dev librust-rand-core+std-dev librust-rand-core-dev 100s librust-rand-dev librust-rand-xorshift-dev librust-rayon-core-dev 100s librust-rayon-dev librust-regex-automata-dev librust-regex-dev 100s librust-regex-syntax-dev librust-rend-dev librust-rkyv-derive-dev 100s librust-rkyv-dev librust-rust-decimal-dev librust-rustc-demangle-dev 100s librust-rustc-hash-dev librust-rustc-std-workspace-core-dev 100s librust-rustc-version-dev librust-rustix-dev 100s librust-rusty-fork+wait-timeout-dev librust-rusty-fork-dev 100s librust-ruzstd-dev librust-ryu-dev librust-same-file-dev 100s librust-scopeguard-dev librust-seahash-dev librust-semver-dev 100s librust-serde-derive-dev librust-serde-dev librust-serde-fmt-dev 100s librust-serde-json-dev librust-serde-test-dev librust-sha1-asm-dev 100s librust-sha1-dev librust-sha2-asm-dev librust-sha2-dev librust-shlex-dev 100s librust-signal-hook-registry-dev librust-simdutf8-dev librust-siphasher-dev 100s librust-slab-dev librust-slog-dev librust-smallvec-dev librust-smol-dev 100s librust-smol-str-dev librust-socket2-dev librust-spin-dev 100s librust-stable-deref-trait-dev librust-static-assertions-dev 100s librust-stringprep-dev librust-strsim-dev librust-subtle-dev 100s librust-sval-buffer-dev librust-sval-derive-dev librust-sval-dev 100s librust-sval-dynamic-dev librust-sval-fmt-dev librust-sval-ref-dev 100s librust-sval-serde-dev librust-syn-1-dev librust-syn-dev librust-tap-dev 100s librust-target-lexicon-dev librust-tempfile-dev librust-termcolor-dev 100s librust-terminal-size-dev librust-tiff-dev librust-time-core-dev 100s librust-time-dev librust-time-macros-dev librust-tiny-keccak-dev 100s librust-tinytemplate-dev librust-tinyvec+tinyvec-macros-dev 100s librust-tinyvec-dev librust-tinyvec-macros-dev librust-tokio-dev 100s librust-tokio-macros-dev librust-tracing-attributes-dev 100s librust-tracing-core-dev librust-tracing-dev librust-traitobject-dev 100s librust-ttf-parser-dev librust-twox-hash-dev librust-typemap-dev 100s librust-typenum-dev librust-unarray-dev librust-uncased-dev 100s librust-unicase-dev librust-unicode-bidi-dev librust-unicode-ident-dev 100s librust-unicode-normalization-dev librust-unicode-segmentation-dev 100s librust-unicode-width-dev librust-unindent-dev librust-unsafe-any-dev 100s librust-utf8parse-dev librust-uuid-dev librust-valuable-derive-dev 100s librust-valuable-dev librust-value-bag-dev librust-value-bag-serde1-dev 100s librust-value-bag-sval2-dev librust-version-check-dev 100s librust-wait-timeout-dev librust-walkdir-dev 100s librust-wasm-bindgen+default-dev librust-wasm-bindgen+spans-dev 100s librust-wasm-bindgen-backend-dev librust-wasm-bindgen-dev 100s librust-wasm-bindgen-macro+spans-dev librust-wasm-bindgen-macro-dev 100s librust-wasm-bindgen-macro-support+spans-dev 100s librust-wasm-bindgen-macro-support-dev librust-wasm-bindgen-shared-dev 100s librust-web-sys-dev librust-webp-dev librust-weezl-dev librust-winapi-dev 100s librust-winapi-i686-pc-windows-gnu-dev librust-winapi-util-dev 100s librust-winapi-x86-64-pc-windows-gnu-dev librust-wyz-dev 100s librust-yeslogic-fontconfig-sys-dev librust-zerocopy-derive-dev 100s librust-zerocopy-dev librust-zeroize-derive-dev librust-zeroize-dev 100s libsharpyuv-dev libsharpyuv0 libstd-rust-1.80 libstd-rust-1.80-dev 100s libstdc++-14-dev libtool libtsan2 libubsan1 libwebp-dev libwebp7 100s libwebpdecoder3 libwebpdemux2 libwebpmux3 llvm llvm-19 llvm-19-linker-tools 100s llvm-19-runtime llvm-runtime m4 pkg-config pkgconf pkgconf-bin po-debconf 100s pybuild-plugin-autopkgtest pybuild-plugin-pyproject python3-all 100s python3-build python3-dateutil python3-hypothesis python3-iniconfig 100s python3-installer python3-packaging python3-pluggy python3-pyproject-hooks 100s python3-pytest python3-regex python3-semantic-version 100s python3-setuptools-rust python3-sortedcontainers python3-tiktoken 100s python3-toml python3-wheel python3.12-dev python3.13 python3.13-minimal 100s rustc rustc-1.80 uuid-dev zlib1g-dev 100s 0 upgraded, 474 newly installed, 0 to remove and 0 not upgraded. 100s Need to get 235 MB/235 MB of archives. 100s After this operation, 982 MB of additional disk space will be used. 100s Get:1 /tmp/autopkgtest.rTBs3P/1-autopkgtest-satdep.deb autopkgtest-satdep amd64 0 [860 B] 100s Get:2 http://ftpmaster.internal/ubuntu plucky/main amd64 libpython3.13-minimal amd64 3.13.0-2 [879 kB] 100s Get:3 http://ftpmaster.internal/ubuntu plucky/main amd64 python3.13-minimal amd64 3.13.0-2 [2188 kB] 100s Get:4 http://ftpmaster.internal/ubuntu plucky/main amd64 m4 amd64 1.4.19-4build1 [244 kB] 100s Get:5 http://ftpmaster.internal/ubuntu plucky/main amd64 autoconf all 2.72-3 [382 kB] 100s Get:6 http://ftpmaster.internal/ubuntu plucky/main amd64 autotools-dev all 20220109.1 [44.9 kB] 100s Get:7 http://ftpmaster.internal/ubuntu plucky/main amd64 automake all 1:1.16.5-1.3ubuntu1 [558 kB] 100s Get:8 http://ftpmaster.internal/ubuntu plucky/main amd64 autopoint all 0.22.5-2 [616 kB] 100s Get:9 http://ftpmaster.internal/ubuntu plucky/main amd64 libisl23 amd64 0.27-1 [685 kB] 100s Get:10 http://ftpmaster.internal/ubuntu plucky/main amd64 libmpc3 amd64 1.3.1-1build2 [55.3 kB] 100s Get:11 http://ftpmaster.internal/ubuntu plucky/main amd64 cpp-14-x86-64-linux-gnu amd64 14.2.0-8ubuntu1 [11.9 MB] 101s Get:12 http://ftpmaster.internal/ubuntu plucky/main amd64 cpp-14 amd64 14.2.0-8ubuntu1 [1030 B] 101s Get:13 http://ftpmaster.internal/ubuntu plucky/main amd64 cpp-x86-64-linux-gnu amd64 4:14.1.0-2ubuntu1 [5452 B] 101s Get:14 http://ftpmaster.internal/ubuntu plucky/main amd64 cpp amd64 4:14.1.0-2ubuntu1 [22.4 kB] 101s Get:15 http://ftpmaster.internal/ubuntu plucky/main amd64 libcc1-0 amd64 14.2.0-8ubuntu1 [47.6 kB] 101s Get:16 http://ftpmaster.internal/ubuntu plucky/main amd64 libgomp1 amd64 14.2.0-8ubuntu1 [148 kB] 101s Get:17 http://ftpmaster.internal/ubuntu plucky/main amd64 libitm1 amd64 14.2.0-8ubuntu1 [29.1 kB] 101s Get:18 http://ftpmaster.internal/ubuntu plucky/main amd64 libasan8 amd64 14.2.0-8ubuntu1 [2998 kB] 101s Get:19 http://ftpmaster.internal/ubuntu plucky/main amd64 liblsan0 amd64 14.2.0-8ubuntu1 [1317 kB] 101s Get:20 http://ftpmaster.internal/ubuntu plucky/main amd64 libtsan2 amd64 14.2.0-8ubuntu1 [2732 kB] 101s Get:21 http://ftpmaster.internal/ubuntu plucky/main amd64 libubsan1 amd64 14.2.0-8ubuntu1 [1177 kB] 101s Get:22 http://ftpmaster.internal/ubuntu plucky/main amd64 libhwasan0 amd64 14.2.0-8ubuntu1 [1634 kB] 101s Get:23 http://ftpmaster.internal/ubuntu plucky/main amd64 libquadmath0 amd64 14.2.0-8ubuntu1 [153 kB] 101s Get:24 http://ftpmaster.internal/ubuntu plucky/main amd64 libgcc-14-dev amd64 14.2.0-8ubuntu1 [2814 kB] 101s Get:25 http://ftpmaster.internal/ubuntu plucky/main amd64 gcc-14-x86-64-linux-gnu amd64 14.2.0-8ubuntu1 [23.3 MB] 102s Get:26 http://ftpmaster.internal/ubuntu plucky/main amd64 gcc-14 amd64 14.2.0-8ubuntu1 [528 kB] 102s Get:27 http://ftpmaster.internal/ubuntu plucky/main amd64 gcc-x86-64-linux-gnu amd64 4:14.1.0-2ubuntu1 [1214 B] 102s Get:28 http://ftpmaster.internal/ubuntu plucky/main amd64 gcc amd64 4:14.1.0-2ubuntu1 [5000 B] 102s Get:29 http://ftpmaster.internal/ubuntu plucky/main amd64 libstdc++-14-dev amd64 14.2.0-8ubuntu1 [2504 kB] 102s Get:30 http://ftpmaster.internal/ubuntu plucky/main amd64 g++-14-x86-64-linux-gnu amd64 14.2.0-8ubuntu1 [13.3 MB] 103s Get:31 http://ftpmaster.internal/ubuntu plucky/main amd64 g++-14 amd64 14.2.0-8ubuntu1 [19.9 kB] 103s Get:32 http://ftpmaster.internal/ubuntu plucky/main amd64 g++-x86-64-linux-gnu amd64 4:14.1.0-2ubuntu1 [966 B] 103s Get:33 http://ftpmaster.internal/ubuntu plucky/main amd64 g++ amd64 4:14.1.0-2ubuntu1 [1100 B] 103s Get:34 http://ftpmaster.internal/ubuntu plucky/main amd64 build-essential amd64 12.10ubuntu1 [4928 B] 103s Get:35 http://ftpmaster.internal/ubuntu plucky/main amd64 libhttp-parser2.9 amd64 2.9.4-6build1 [22.3 kB] 103s Get:36 http://ftpmaster.internal/ubuntu plucky/main amd64 libgit2-1.7 amd64 1.7.2+ds-1ubuntu3 [529 kB] 103s Get:37 http://ftpmaster.internal/ubuntu plucky/main amd64 libstd-rust-1.80 amd64 1.80.1+dfsg0ubuntu1-0ubuntu1 [21.5 MB] 103s Get:38 http://ftpmaster.internal/ubuntu plucky/main amd64 libstd-rust-1.80-dev amd64 1.80.1+dfsg0ubuntu1-0ubuntu1 [41.7 MB] 105s Get:39 http://ftpmaster.internal/ubuntu plucky/main amd64 rustc-1.80 amd64 1.80.1+dfsg0ubuntu1-0ubuntu1 [3334 kB] 105s Get:40 http://ftpmaster.internal/ubuntu plucky/main amd64 cargo-1.80 amd64 1.80.1+dfsg0ubuntu1-0ubuntu1 [6148 kB] 105s Get:41 http://ftpmaster.internal/ubuntu plucky/main amd64 libjsoncpp25 amd64 1.9.5-6build1 [82.8 kB] 105s Get:42 http://ftpmaster.internal/ubuntu plucky/main amd64 librhash0 amd64 1.4.3-3build1 [129 kB] 105s Get:43 http://ftpmaster.internal/ubuntu plucky/main amd64 cmake-data all 3.30.3-1 [2246 kB] 105s Get:44 http://ftpmaster.internal/ubuntu plucky/main amd64 cmake amd64 3.30.3-1 [12.0 MB] 105s Get:45 http://ftpmaster.internal/ubuntu plucky/main amd64 libdebhelper-perl all 13.20ubuntu1 [94.2 kB] 105s Get:46 http://ftpmaster.internal/ubuntu plucky/main amd64 libtool all 2.4.7-8 [166 kB] 105s Get:47 http://ftpmaster.internal/ubuntu plucky/main amd64 dh-autoreconf all 20 [16.1 kB] 105s Get:48 http://ftpmaster.internal/ubuntu plucky/main amd64 libarchive-zip-perl all 1.68-1 [90.2 kB] 105s Get:49 http://ftpmaster.internal/ubuntu plucky/main amd64 libfile-stripnondeterminism-perl all 1.14.0-1 [20.1 kB] 105s Get:50 http://ftpmaster.internal/ubuntu plucky/main amd64 dh-strip-nondeterminism all 1.14.0-1 [5058 B] 105s Get:51 http://ftpmaster.internal/ubuntu plucky/main amd64 debugedit amd64 1:5.1-1 [46.9 kB] 105s Get:52 http://ftpmaster.internal/ubuntu plucky/main amd64 dwz amd64 0.15-1build6 [115 kB] 105s Get:53 http://ftpmaster.internal/ubuntu plucky/main amd64 gettext amd64 0.22.5-2 [948 kB] 106s Get:54 http://ftpmaster.internal/ubuntu plucky/main amd64 intltool-debian all 0.35.0+20060710.6 [23.2 kB] 106s Get:55 http://ftpmaster.internal/ubuntu plucky/main amd64 po-debconf all 1.0.21+nmu1 [233 kB] 106s Get:56 http://ftpmaster.internal/ubuntu plucky/main amd64 debhelper all 13.20ubuntu1 [893 kB] 106s Get:57 http://ftpmaster.internal/ubuntu plucky/universe amd64 dh-python all 6.20241024 [112 kB] 106s Get:58 http://ftpmaster.internal/ubuntu plucky/main amd64 fonts-dejavu-mono all 2.37-8 [502 kB] 106s Get:59 http://ftpmaster.internal/ubuntu plucky/main amd64 fonts-dejavu-core all 2.37-8 [835 kB] 106s Get:60 http://ftpmaster.internal/ubuntu plucky/main amd64 fontconfig-config amd64 2.15.0-1.1ubuntu2 [37.3 kB] 106s Get:61 http://ftpmaster.internal/ubuntu plucky/main amd64 libbrotli-dev amd64 1.1.0-2build3 [381 kB] 106s Get:62 http://ftpmaster.internal/ubuntu plucky/main amd64 libbz2-dev amd64 1.0.8-6 [33.8 kB] 106s Get:63 http://ftpmaster.internal/ubuntu plucky/main amd64 libexpat1-dev amd64 2.6.4-1 [148 kB] 106s Get:64 http://ftpmaster.internal/ubuntu plucky/main amd64 libfontconfig1 amd64 2.15.0-1.1ubuntu2 [139 kB] 106s Get:65 http://ftpmaster.internal/ubuntu plucky/main amd64 zlib1g-dev amd64 1:1.3.dfsg+really1.3.1-1ubuntu1 [895 kB] 106s Get:66 http://ftpmaster.internal/ubuntu plucky/main amd64 libpng-dev amd64 1.6.44-2 [300 kB] 106s Get:67 http://ftpmaster.internal/ubuntu plucky/main amd64 libfreetype-dev amd64 2.13.3+dfsg-1 [575 kB] 106s Get:68 http://ftpmaster.internal/ubuntu plucky/main amd64 uuid-dev amd64 2.40.2-1ubuntu1 [52.7 kB] 106s Get:69 http://ftpmaster.internal/ubuntu plucky/main amd64 libpkgconf3 amd64 1.8.1-4 [32.3 kB] 106s Get:70 http://ftpmaster.internal/ubuntu plucky/main amd64 pkgconf-bin amd64 1.8.1-4 [21.6 kB] 106s Get:71 http://ftpmaster.internal/ubuntu plucky/main amd64 pkgconf amd64 1.8.1-4 [16.8 kB] 106s Get:72 http://ftpmaster.internal/ubuntu plucky/main amd64 libfontconfig-dev amd64 2.15.0-1.1ubuntu2 [161 kB] 106s Get:73 http://ftpmaster.internal/ubuntu plucky/main amd64 libpython3.12-dev amd64 3.12.7-3 [5699 kB] 106s Get:74 http://ftpmaster.internal/ubuntu plucky-proposed/main amd64 libpython3-dev amd64 3.12.7-1 [10.3 kB] 106s Get:75 http://ftpmaster.internal/ubuntu plucky/main amd64 libpython3.13-stdlib amd64 3.13.0-2 [2107 kB] 106s Get:76 http://ftpmaster.internal/ubuntu plucky/main amd64 libpython3.13 amd64 3.13.0-2 [2321 kB] 106s Get:77 http://ftpmaster.internal/ubuntu plucky/main amd64 libpython3.13-dev amd64 3.13.0-2 [5488 kB] 106s Get:78 http://ftpmaster.internal/ubuntu plucky-proposed/main amd64 libpython3-all-dev amd64 3.12.7-1 [916 B] 106s Get:79 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ab-glyph-rasterizer-dev amd64 0.1.7-1 [12.2 kB] 106s Get:80 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-libm-dev amd64 0.2.8-1 [101 kB] 106s Get:81 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ab-glyph-rasterizer+libm-dev amd64 0.1.7-1 [1064 B] 106s Get:82 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-core-maths-dev amd64 0.1.0-2 [7944 B] 106s Get:83 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ttf-parser-dev amd64 0.24.1-1 [148 kB] 106s Get:84 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-owned-ttf-parser-dev amd64 0.24.0-1 [129 kB] 106s Get:85 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ab-glyph-dev amd64 0.2.28-1 [20.7 kB] 106s Get:86 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-cfg-if-dev amd64 1.0.0-1 [10.5 kB] 106s Get:87 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-cpp-demangle-dev amd64 0.4.0-1 [66.1 kB] 106s Get:88 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-fallible-iterator-dev amd64 0.3.0-2 [20.3 kB] 106s Get:89 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-unicode-ident-dev amd64 1.0.13-1 [38.5 kB] 106s Get:90 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-proc-macro2-dev amd64 1.0.86-1 [44.8 kB] 106s Get:91 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-quote-dev amd64 1.0.37-1 [29.5 kB] 106s Get:92 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-syn-dev amd64 2.0.85-1 [219 kB] 106s Get:93 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-derive-arbitrary-dev amd64 1.3.2-1 [12.3 kB] 106s Get:94 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-arbitrary-dev amd64 1.3.2-1 [31.4 kB] 106s Get:95 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-equivalent-dev amd64 1.0.1-1 [8238 B] 106s Get:96 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-critical-section-dev amd64 1.1.3-1 [20.5 kB] 106s Get:97 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-serde-derive-dev amd64 1.0.210-1 [50.1 kB] 106s Get:98 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-serde-dev amd64 1.0.210-2 [66.4 kB] 106s Get:99 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-portable-atomic-dev amd64 1.9.0-4 [124 kB] 106s Get:100 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-libc-dev amd64 0.2.155-1 [367 kB] 106s Get:101 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-getrandom-dev amd64 0.2.12-1 [36.4 kB] 106s Get:102 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-smallvec-dev amd64 1.13.2-1 [35.5 kB] 107s Get:103 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-parking-lot-core-dev amd64 0.9.10-1 [32.6 kB] 107s Get:104 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-once-cell-dev amd64 1.20.2-1 [31.9 kB] 107s Get:105 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-crunchy-dev amd64 0.2.2-1 [5336 B] 107s Get:106 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tiny-keccak-dev amd64 2.0.2-1 [20.9 kB] 107s Get:107 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-const-random-macro-dev amd64 0.1.16-2 [10.5 kB] 107s Get:108 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-const-random-dev amd64 0.1.17-2 [8584 B] 107s Get:109 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-version-check-dev amd64 0.9.5-1 [16.9 kB] 107s Get:110 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-byteorder-dev amd64 1.5.0-1 [22.4 kB] 107s Get:111 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-zerocopy-derive-dev amd64 0.7.32-2 [29.7 kB] 107s Get:112 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-zerocopy-dev amd64 0.7.32-1 [116 kB] 107s Get:113 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ahash-dev all 0.8.11-8 [37.9 kB] 107s Get:114 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-allocator-api2-dev amd64 0.2.16-1 [54.8 kB] 107s Get:115 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-compiler-builtins-dev amd64 0.1.101-1 [156 kB] 107s Get:116 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-either-dev amd64 1.13.0-1 [20.2 kB] 107s Get:117 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-crossbeam-utils-dev amd64 0.8.19-1 [41.1 kB] 107s Get:118 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-crossbeam-epoch-dev amd64 0.9.18-1 [42.3 kB] 107s Get:119 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-crossbeam-epoch+std-dev amd64 0.9.18-1 [1128 B] 107s Get:120 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-crossbeam-deque-dev amd64 0.8.5-1 [22.4 kB] 107s Get:121 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rayon-core-dev amd64 1.12.1-1 [63.7 kB] 107s Get:122 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rayon-dev amd64 1.10.0-1 [149 kB] 107s Get:123 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rustc-std-workspace-core-dev amd64 1.0.0-1 [3020 B] 107s Get:124 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-hashbrown-dev amd64 0.14.5-5 [110 kB] 107s Get:125 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-indexmap-dev amd64 2.2.6-1 [66.7 kB] 107s Get:126 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-stable-deref-trait-dev amd64 1.2.0-1 [9794 B] 107s Get:127 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-gimli-dev amd64 0.28.1-2 [209 kB] 107s Get:128 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-memmap2-dev amd64 0.9.3-1 [30.8 kB] 107s Get:129 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-crc32fast-dev amd64 1.4.2-1 [39.8 kB] 107s Get:130 http://ftpmaster.internal/ubuntu plucky/main amd64 pkg-config amd64 1.8.1-4 [7362 B] 107s Get:131 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-pkg-config-dev amd64 0.3.27-1 [21.5 kB] 107s Get:132 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-libz-sys-dev amd64 1.1.20-1 [19.7 kB] 107s Get:133 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-adler-dev amd64 1.0.2-2 [15.3 kB] 107s Get:134 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-miniz-oxide-dev amd64 0.7.1-1 [51.5 kB] 107s Get:135 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-flate2-dev amd64 1.0.34-1 [94.5 kB] 107s Get:136 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-sval-derive-dev amd64 2.6.1-2 [11.0 kB] 107s Get:137 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-sval-dev amd64 2.6.1-2 [28.0 kB] 107s Get:138 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-sval-ref-dev amd64 2.6.1-1 [8942 B] 107s Get:139 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-erased-serde-dev amd64 0.3.31-1 [22.7 kB] 107s Get:140 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-serde-fmt-dev all 1.0.3-3 [6956 B] 107s Get:141 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-syn-1-dev amd64 1.0.109-2 [188 kB] 107s Get:142 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-no-panic-dev amd64 0.1.13-1 [11.3 kB] 107s Get:143 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-itoa-dev amd64 1.0.9-1 [13.1 kB] 107s Get:144 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ryu-dev amd64 1.0.15-1 [41.7 kB] 107s Get:145 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-serde-json-dev amd64 1.0.128-1 [128 kB] 107s Get:146 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-serde-test-dev amd64 1.0.171-1 [20.6 kB] 107s Get:147 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-value-bag-serde1-dev amd64 1.9.0-1 [7822 B] 107s Get:148 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-sval-buffer-dev amd64 2.6.1-1 [16.7 kB] 107s Get:149 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-sval-dynamic-dev amd64 2.6.1-1 [9540 B] 107s Get:150 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-sval-fmt-dev amd64 2.6.1-1 [12.0 kB] 107s Get:151 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-sval-serde-dev amd64 2.6.1-1 [13.2 kB] 107s Get:152 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-value-bag-sval2-dev amd64 1.9.0-1 [7860 B] 107s Get:153 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-value-bag-dev amd64 1.9.0-1 [37.6 kB] 107s Get:154 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-log-dev amd64 0.4.22-1 [43.0 kB] 107s Get:155 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-memchr-dev amd64 2.7.4-1 [71.8 kB] 107s Get:156 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ppv-lite86-dev amd64 0.2.16-1 [21.9 kB] 107s Get:157 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rand-core-dev amd64 0.6.4-2 [23.8 kB] 107s Get:158 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rand-chacha-dev amd64 0.3.1-2 [16.9 kB] 107s Get:159 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rand-core+getrandom-dev amd64 0.6.4-2 [1052 B] 107s Get:160 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rand-core+serde-dev amd64 0.6.4-2 [1108 B] 108s Get:161 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rand-core+std-dev amd64 0.6.4-2 [1050 B] 108s Get:162 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rand-dev amd64 0.8.5-1 [77.5 kB] 108s Get:163 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-unicode-segmentation-dev amd64 1.11.0-1 [74.2 kB] 108s Get:164 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-convert-case-dev amd64 0.6.0-2 [19.4 kB] 108s Get:165 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-semver-dev amd64 1.0.23-1 [30.6 kB] 108s Get:166 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rustc-version-dev amd64 0.4.0-1 [13.8 kB] 108s Get:167 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-derive-more-0.99-dev amd64 0.99.18-1 [49.9 kB] 108s Get:168 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-cfg-if-0.1-dev amd64 0.1.10-2 [10.2 kB] 108s Get:169 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-blobby-dev amd64 0.3.1-1 [11.3 kB] 108s Get:170 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-typenum-dev amd64 1.17.0-2 [41.2 kB] 108s Get:171 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-zeroize-derive-dev amd64 1.4.2-1 [12.7 kB] 108s Get:172 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-zeroize-dev amd64 1.8.1-1 [21.6 kB] 108s Get:173 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-generic-array-dev amd64 0.14.7-1 [16.9 kB] 108s Get:174 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-block-buffer-dev amd64 0.10.2-2 [12.2 kB] 108s Get:175 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-const-oid-dev amd64 0.9.3-1 [40.9 kB] 108s Get:176 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-crypto-common-dev amd64 0.1.6-1 [10.5 kB] 108s Get:177 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-subtle-dev amd64 2.6.1-1 [16.1 kB] 108s Get:178 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-digest-dev amd64 0.10.7-2 [20.9 kB] 108s Get:179 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-static-assertions-dev amd64 1.1.0-1 [19.0 kB] 108s Get:180 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-twox-hash-dev amd64 1.6.3-1 [21.6 kB] 108s Get:181 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ruzstd-dev amd64 0.5.0-1 [44.6 kB] 108s Get:182 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-object-dev amd64 0.32.2-1 [228 kB] 108s Get:183 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rustc-demangle-dev amd64 0.1.21-1 [27.7 kB] 108s Get:184 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-addr2line-dev amd64 0.21.0-2 [36.4 kB] 108s Get:185 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-aho-corasick-dev amd64 1.1.3-1 [146 kB] 108s Get:186 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bitflags-1-dev amd64 1.3.2-5 [25.3 kB] 108s Get:187 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-anes-dev amd64 0.1.6-1 [21.1 kB] 108s Get:188 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-anstyle-dev amd64 1.0.8-1 [16.7 kB] 108s Get:189 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-arrayvec-dev amd64 0.7.4-2 [29.9 kB] 108s Get:190 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-utf8parse-dev amd64 0.2.1-1 [15.0 kB] 108s Get:191 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-anstyle-parse-dev amd64 0.2.1-1 [17.1 kB] 108s Get:192 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-anstyle-query-dev amd64 1.0.0-1 [9768 B] 108s Get:193 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-colorchoice-dev amd64 1.0.0-1 [8336 B] 108s Get:194 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-anstream-dev amd64 0.6.15-1 [25.7 kB] 108s Get:195 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-jobserver-dev amd64 0.1.32-1 [29.1 kB] 108s Get:196 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-shlex-dev amd64 1.3.0-1 [20.1 kB] 108s Get:197 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-cc-dev amd64 1.1.14-1 [73.6 kB] 108s Get:198 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-backtrace-dev amd64 0.3.69-2 [69.9 kB] 108s Get:199 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-anyhow-dev amd64 1.0.86-1 [44.3 kB] 108s Get:200 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bytecheck-derive-dev amd64 0.6.12-1 [7086 B] 108s Get:201 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ptr-meta-derive-dev amd64 0.1.4-1 [3964 B] 108s Get:202 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ptr-meta-dev amd64 0.1.4-1 [7342 B] 108s Get:203 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-simdutf8-dev amd64 0.1.4-4 [27.2 kB] 108s Get:204 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bytemuck-derive-dev amd64 1.5.0-2 [18.7 kB] 108s Get:205 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bytemuck-dev amd64 1.14.0-1 [42.7 kB] 108s Get:206 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-atomic-dev amd64 0.6.0-1 [15.5 kB] 108s Get:207 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-md5-asm-dev amd64 0.5.0-2 [7512 B] 108s Get:208 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-md-5-dev amd64 0.10.6-1 [17.5 kB] 108s Get:209 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-cpufeatures-dev amd64 0.2.11-1 [14.9 kB] 108s Get:210 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-sha1-asm-dev amd64 0.5.1-2 [8056 B] 108s Get:211 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-sha1-dev amd64 0.10.6-1 [16.0 kB] 108s Get:212 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-slog-dev amd64 2.7.0-1 [44.0 kB] 108s Get:213 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-uuid-dev amd64 1.10.0-1 [44.2 kB] 108s Get:214 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bytecheck-dev amd64 0.6.12-1 [10.2 kB] 108s Get:215 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-autocfg-dev amd64 1.1.0-1 [15.1 kB] 109s Get:216 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-num-traits-dev amd64 0.2.19-2 [46.2 kB] 109s Get:217 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-funty-dev amd64 2.0.0-1 [13.8 kB] 109s Get:218 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-radium-dev amd64 1.1.0-1 [14.9 kB] 109s Get:219 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tap-dev amd64 1.0.1-1 [12.7 kB] 109s Get:220 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-traitobject-dev amd64 0.1.0-1 [4540 B] 109s Get:221 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-unsafe-any-dev amd64 0.4.2-2 [4622 B] 109s Get:222 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-typemap-dev amd64 0.3.3-2 [6724 B] 109s Get:223 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-wyz-dev amd64 0.5.1-1 [19.7 kB] 109s Get:224 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bitvec-dev amd64 1.0.1-1 [179 kB] 109s Get:225 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bytes-dev amd64 1.8.0-1 [56.9 kB] 109s Get:226 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rend-dev amd64 0.4.0-1 [10.3 kB] 109s Get:227 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rkyv-derive-dev amd64 0.7.44-1 [17.5 kB] 109s Get:228 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-seahash-dev amd64 4.1.0-1 [25.1 kB] 109s Get:229 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-smol-str-dev amd64 0.2.0-1 [15.2 kB] 109s Get:230 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tinyvec-dev amd64 1.6.0-2 [37.7 kB] 109s Get:231 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tinyvec-macros-dev amd64 0.1.0-1 [3852 B] 109s Get:232 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tinyvec+tinyvec-macros-dev amd64 1.6.0-2 [1124 B] 109s Get:233 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rkyv-dev amd64 0.7.44-1 [94.4 kB] 109s Get:234 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-num-complex-dev amd64 0.4.6-2 [30.8 kB] 109s Get:235 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-approx-dev amd64 0.5.1-1 [16.0 kB] 109s Get:236 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-array-init-dev amd64 2.0.1-1 [12.3 kB] 109s Get:237 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-attributes-dev all 1.1.2-6 [6756 B] 109s Get:238 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-concurrent-queue-dev amd64 2.5.0-4 [23.9 kB] 109s Get:239 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-parking-dev amd64 2.2.0-1 [11.6 kB] 109s Get:240 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-pin-project-lite-dev amd64 0.2.13-1 [30.2 kB] 109s Get:241 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-event-listener-dev all 5.3.1-8 [29.6 kB] 109s Get:242 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-event-listener-strategy-dev amd64 0.5.2-3 [12.6 kB] 109s Get:243 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-futures-core-dev amd64 0.3.30-1 [16.7 kB] 109s Get:244 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-channel-dev all 2.3.1-8 [13.1 kB] 109s Get:245 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-task-dev all 4.7.1-3 [29.4 kB] 109s Get:246 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-fastrand-dev amd64 2.1.1-1 [17.8 kB] 109s Get:247 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-futures-io-dev amd64 0.3.31-1 [11.2 kB] 109s Get:248 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-futures-lite-dev amd64 2.3.0-2 [38.6 kB] 109s Get:249 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-slab-dev amd64 0.4.9-1 [21.2 kB] 109s Get:250 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-executor-dev all 1.13.1-1 [18.7 kB] 109s Get:251 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-lock-dev all 3.4.0-4 [29.3 kB] 109s Get:252 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-atomic-waker-dev amd64 1.1.2-1 [14.3 kB] 109s Get:253 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tracing-attributes-dev amd64 0.1.27-1 [33.3 kB] 109s Get:254 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-valuable-derive-dev amd64 0.1.0-1 [5942 B] 109s Get:255 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-valuable-dev amd64 0.1.0-4 [23.5 kB] 109s Get:256 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tracing-core-dev amd64 0.1.32-1 [53.8 kB] 109s Get:257 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tracing-dev amd64 0.1.40-1 [69.5 kB] 109s Get:258 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-blocking-dev all 1.6.1-5 [17.5 kB] 109s Get:259 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-fs-dev all 2.1.2-4 [15.3 kB] 109s Get:260 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bitflags-dev amd64 2.6.0-1 [41.1 kB] 109s Get:261 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-compiler-builtins+core-dev amd64 0.1.101-1 [1090 B] 109s Get:262 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-compiler-builtins+rustc-dep-of-std-dev amd64 0.1.101-1 [1104 B] 109s Get:263 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-errno-dev amd64 0.3.8-1 [13.0 kB] 109s Get:264 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-linux-raw-sys-dev amd64 0.4.14-1 [138 kB] 109s Get:265 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rustix-dev amd64 0.38.32-1 [274 kB] 109s Get:266 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-polling-dev amd64 3.4.0-1 [47.8 kB] 109s Get:267 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-io-dev amd64 2.3.3-4 [41.0 kB] 109s Get:268 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-mio-dev amd64 1.0.2-2 [87.6 kB] 109s Get:269 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-owning-ref-dev amd64 0.4.1-1 [13.7 kB] 109s Get:270 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-scopeguard-dev amd64 1.2.0-1 [13.3 kB] 109s Get:271 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-lock-api-dev amd64 0.4.12-1 [22.9 kB] 109s Get:272 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-parking-lot-dev amd64 0.12.3-1 [38.7 kB] 109s Get:273 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-signal-hook-registry-dev amd64 1.4.0-1 [19.2 kB] 109s Get:274 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-socket2-dev amd64 0.5.7-1 [48.3 kB] 109s Get:275 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tokio-macros-dev amd64 2.4.0-2 [14.0 kB] 109s Get:276 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tokio-dev amd64 1.39.3-3 [561 kB] 109s Get:277 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-global-executor-dev amd64 2.4.1-5 [14.6 kB] 109s Get:278 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-net-dev all 2.0.0-4 [14.6 kB] 109s Get:279 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-signal-dev amd64 0.2.10-1 [16.0 kB] 109s Get:280 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-process-dev all 2.3.0-1 [21.2 kB] 110s Get:281 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-kv-log-macro-dev all 1.0.8-4 [7290 B] 110s Get:282 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-pin-utils-dev amd64 0.1.0-1 [9340 B] 110s Get:283 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-async-std-dev all 1.13.0-1 [170 kB] 110s Get:284 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-base64-dev amd64 0.21.7-1 [65.1 kB] 110s Get:285 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bit-vec-dev amd64 0.6.3-1 [21.1 kB] 110s Get:286 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bit-set-dev amd64 0.5.2-1 [15.7 kB] 110s Get:287 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bit-set+std-dev amd64 0.5.2-1 [1084 B] 110s Get:288 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-regex-syntax-dev amd64 0.8.2-1 [200 kB] 110s Get:289 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-regex-automata-dev amd64 0.4.7-1 [424 kB] 110s Get:290 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bstr-dev amd64 1.7.0-2build1 [271 kB] 110s Get:291 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-bumpalo-dev amd64 3.16.0-1 [75.7 kB] 110s Get:292 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-cast-dev amd64 0.3.0-1 [13.1 kB] 110s Get:293 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-iana-time-zone-dev amd64 0.1.60-1 [25.1 kB] 110s Get:294 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-wasm-bindgen-shared-dev amd64 0.2.87-1 [9090 B] 110s Get:295 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-wasm-bindgen-backend-dev amd64 0.2.87-1 [27.0 kB] 110s Get:296 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-wasm-bindgen-macro-support-dev amd64 0.2.87-1 [21.2 kB] 110s Get:297 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-wasm-bindgen-macro-dev amd64 0.2.87-1 [16.6 kB] 110s Get:298 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-wasm-bindgen-dev amd64 0.2.87-1 [157 kB] 110s Get:299 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-wasm-bindgen-macro-support+spans-dev amd64 0.2.87-1 [1074 B] 110s Get:300 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-wasm-bindgen-macro+spans-dev amd64 0.2.87-1 [1058 B] 110s Get:301 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-wasm-bindgen+spans-dev amd64 0.2.87-1 [1038 B] 110s Get:302 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-wasm-bindgen+default-dev amd64 0.2.87-1 [1046 B] 110s Get:303 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-js-sys-dev amd64 0.3.64-1 [71.9 kB] 110s Get:304 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-pure-rust-locales-dev amd64 0.8.1-1 [112 kB] 110s Get:305 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-chrono-dev amd64 0.4.38-2 [172 kB] 110s Get:306 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-regex-dev amd64 1.10.6-1 [199 kB] 110s Get:307 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-parse-zoneinfo-dev amd64 0.3.0-1 [71.0 kB] 110s Get:308 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-siphasher-dev amd64 0.3.10-1 [12.0 kB] 110s Get:309 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-phf-shared-dev amd64 0.11.2-1 [15.6 kB] 110s Get:310 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-phf-dev amd64 0.11.2-1 [21.6 kB] 110s Get:311 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-uncased-dev amd64 0.9.6-2 [12.2 kB] 110s Get:312 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-phf-shared+uncased-dev amd64 0.11.2-1 [1026 B] 110s Get:313 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-phf+uncased-dev amd64 0.11.2-1 [1028 B] 110s Get:314 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ciborium-io-dev amd64 0.2.2-1 [8180 B] 110s Get:315 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-half-dev amd64 1.8.2-4 [34.8 kB] 110s Get:316 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ciborium-ll-dev amd64 0.2.2-1 [15.8 kB] 110s Get:317 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ciborium-dev amd64 0.2.2-2 [32.6 kB] 110s Get:318 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-clap-lex-dev amd64 0.7.2-2 [14.3 kB] 110s Get:319 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-strsim-dev amd64 0.11.1-1 [15.9 kB] 110s Get:320 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-terminal-size-dev amd64 0.3.0-2 [12.6 kB] 110s Get:321 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-unicase-dev amd64 2.7.0-1 [19.4 kB] 110s Get:322 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-unicode-width-dev amd64 0.1.14-1 [196 kB] 110s Get:323 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-clap-builder-dev amd64 4.5.15-2 [135 kB] 110s Get:324 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-heck-dev amd64 0.4.1-1 [13.3 kB] 110s Get:325 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-clap-derive-dev amd64 4.5.13-2 [29.3 kB] 110s Get:326 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-clap-dev amd64 4.5.16-1 [52.3 kB] 110s Get:327 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-csv-core-dev amd64 0.1.11-1 [25.9 kB] 110s Get:328 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-csv-dev amd64 1.3.0-1 [729 kB] 110s Get:329 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-futures-sink-dev amd64 0.3.31-1 [10.1 kB] 110s Get:330 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-futures-channel-dev amd64 0.3.30-1 [31.8 kB] 110s Get:331 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-futures-task-dev amd64 0.3.30-1 [13.5 kB] 110s Get:332 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-futures-macro-dev amd64 0.3.30-1 [13.3 kB] 110s Get:333 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-futures-util-dev amd64 0.3.30-2 [127 kB] 110s Get:334 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-num-cpus-dev amd64 1.16.0-1 [18.1 kB] 110s Get:335 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-futures-executor-dev amd64 0.3.30-1 [19.8 kB] 111s Get:336 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-futures-dev amd64 0.3.30-2 [53.2 kB] 111s Get:337 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-is-terminal-dev amd64 0.4.13-1 [8264 B] 111s Get:338 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-itertools-dev amd64 0.10.5-1 [101 kB] 111s Get:339 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-oorandom-dev amd64 11.1.3-1 [11.3 kB] 111s Get:340 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-winapi-i686-pc-windows-gnu-dev amd64 0.4.0-1 [3652 B] 111s Get:341 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-winapi-x86-64-pc-windows-gnu-dev amd64 0.4.0-1 [3660 B] 111s Get:342 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-winapi-dev amd64 0.3.9-1 [953 kB] 111s Get:343 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-dirs-sys-next-dev amd64 0.1.1-1 [12.1 kB] 111s Get:344 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-dirs-next-dev amd64 2.0.0-1 [13.1 kB] 111s Get:345 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-float-ord-dev amd64 0.3.2-1 [9402 B] 111s Get:346 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-cmake-dev amd64 0.1.45-1 [16.0 kB] 111s Get:347 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-freetype-sys-dev amd64 0.13.1-1 [11.8 kB] 111s Get:348 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-freetype-dev amd64 0.7.0-4 [20.4 kB] 111s Get:349 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-spin-dev amd64 0.9.8-4 [33.4 kB] 111s Get:350 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-lazy-static-dev amd64 1.5.0-1 [14.2 kB] 111s Get:351 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-pathfinder-simd-dev amd64 0.5.2-1 [20.1 kB] 111s Get:352 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-pathfinder-geometry-dev amd64 0.5.1-1 [13.2 kB] 111s Get:353 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-winapi-util-dev amd64 0.1.6-1 [14.0 kB] 111s Get:354 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-same-file-dev amd64 1.0.6-1 [11.5 kB] 111s Get:355 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-walkdir-dev amd64 2.5.0-1 [24.5 kB] 111s Get:356 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-const-cstr-dev amd64 0.3.0-1 [9068 B] 111s Get:357 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-libloading-dev amd64 0.8.5-1 [29.2 kB] 111s Get:358 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-dlib-dev amd64 0.5.2-2 [7972 B] 111s Get:359 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-yeslogic-fontconfig-sys-dev amd64 3.0.1-1 [8110 B] 111s Get:360 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-font-kit-dev amd64 0.11.0-2 [56.2 kB] 111s Get:361 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-color-quant-dev amd64 1.1.0-1 [8462 B] 111s Get:362 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-weezl-dev amd64 0.1.5-1 [30.3 kB] 111s Get:363 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-gif-dev amd64 0.11.3-1 [31.9 kB] 111s Get:364 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-jpeg-decoder-dev amd64 0.3.0-1 [717 kB] 111s Get:365 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-num-integer-dev amd64 0.1.46-1 [22.6 kB] 111s Get:366 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-humantime-dev amd64 2.1.0-1 [18.2 kB] 111s Get:367 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-termcolor-dev amd64 1.4.1-1 [19.7 kB] 111s Get:368 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-env-logger-dev amd64 0.10.2-2 [34.4 kB] 111s Get:369 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-quickcheck-dev amd64 1.0.3-3 [27.9 kB] 111s Get:370 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-num-bigint-dev amd64 0.4.6-1 [84.9 kB] 111s Get:371 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-num-rational-dev amd64 0.4.2-1 [28.7 kB] 111s Get:372 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-png-dev amd64 0.17.7-3 [63.4 kB] 111s Get:373 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-qoi-dev amd64 0.4.1-2 [56.7 kB] 111s Get:374 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tiff-dev amd64 0.9.0-1 [1413 kB] 111s Get:375 http://ftpmaster.internal/ubuntu plucky/main amd64 libsharpyuv0 amd64 1.4.0-0.1 [17.5 kB] 111s Get:376 http://ftpmaster.internal/ubuntu plucky/main amd64 libwebp7 amd64 1.4.0-0.1 [231 kB] 111s Get:377 http://ftpmaster.internal/ubuntu plucky/main amd64 libwebpdemux2 amd64 1.4.0-0.1 [12.4 kB] 111s Get:378 http://ftpmaster.internal/ubuntu plucky/main amd64 libwebpmux3 amd64 1.4.0-0.1 [25.8 kB] 111s Get:379 http://ftpmaster.internal/ubuntu plucky/main amd64 libwebpdecoder3 amd64 1.4.0-0.1 [115 kB] 111s Get:380 http://ftpmaster.internal/ubuntu plucky/main amd64 libsharpyuv-dev amd64 1.4.0-0.1 [19.4 kB] 111s Get:381 http://ftpmaster.internal/ubuntu plucky/main amd64 libwebp-dev amd64 1.4.0-0.1 [371 kB] 111s Get:382 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-libwebp-sys-dev amd64 0.9.5-1build1 [1357 kB] 111s Get:383 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-webp-dev amd64 0.2.6-1 [1846 kB] 112s Get:384 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-image-dev amd64 0.24.7-2 [229 kB] 112s Get:385 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-plotters-backend-dev amd64 0.3.7-1 [15.7 kB] 112s Get:386 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-plotters-bitmap-dev amd64 0.3.3-3 [17.1 kB] 112s Get:387 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-plotters-svg-dev amd64 0.3.5-1 [9258 B] 112s Get:388 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-web-sys-dev amd64 0.3.64-2 [581 kB] 112s Get:389 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-plotters-dev amd64 0.3.5-4 [118 kB] 112s Get:390 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-smol-dev all 2.0.2-1 [205 kB] 112s Get:391 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tinytemplate-dev amd64 1.2.1-1 [26.8 kB] 112s Get:392 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-criterion-dev all 0.5.1-6 [104 kB] 112s Get:393 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-phf-generator-dev amd64 0.11.2-2 [12.3 kB] 112s Get:394 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-phf-codegen-dev amd64 0.11.2-1 [14.3 kB] 112s Get:395 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-chrono-tz-build-dev amd64 0.2.1-1 [12.1 kB] 112s Get:396 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-chrono-tz-dev amd64 0.8.6-2 [513 kB] 112s Get:397 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ctor-dev amd64 0.1.26-1 [12.0 kB] 112s Get:398 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-powerfmt-macros-dev amd64 0.1.0-1 [10.5 kB] 112s Get:399 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-powerfmt-dev amd64 0.2.0-1 [16.5 kB] 112s Get:400 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-deranged-dev amd64 0.3.11-1 [18.4 kB] 112s Get:401 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-eui48-dev amd64 1.1.0-2 [16.1 kB] 112s Get:402 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-indenter-dev amd64 0.3.3-1 [8646 B] 112s Get:403 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-eyre-dev amd64 0.6.12-1 [38.0 kB] 112s Get:404 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-eyre+default-dev amd64 0.6.12-1 [1050 B] 112s Get:405 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-fancy-regex-dev amd64 0.11.0-2 [54.7 kB] 112s Get:406 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-fnv-dev amd64 1.0.7-1 [12.8 kB] 112s Get:407 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-geo-types-dev amd64 0.7.11-2 [32.8 kB] 112s Get:408 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-ghost-dev amd64 0.1.5-1 [16.1 kB] 112s Get:409 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-hmac-dev amd64 0.12.1-1 [43.9 kB] 112s Get:410 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-indoc-dev amd64 2.0.5-1 [16.7 kB] 112s Get:411 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-inventory-dev amd64 0.3.2-1 [13.5 kB] 112s Get:412 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-memoffset-dev amd64 0.8.0-1 [10.9 kB] 112s Get:413 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-num-conv-dev amd64 0.1.0-1 [8990 B] 112s Get:414 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-num-threads-dev amd64 0.1.7-1 [9152 B] 112s Get:415 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-postgres-derive-dev amd64 0.4.5-1 [13.4 kB] 112s Get:416 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-sha2-asm-dev amd64 0.6.2-2 [14.4 kB] 112s Get:417 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-sha2-dev amd64 0.10.8-1 [25.6 kB] 112s Get:418 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-unicode-bidi-dev amd64 0.3.13-1 [39.8 kB] 112s Get:419 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-unicode-normalization-dev amd64 0.1.22-1 [104 kB] 112s Get:420 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-stringprep-dev amd64 0.1.2-1 [16.5 kB] 112s Get:421 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-postgres-protocol-dev amd64 0.6.6-2 [25.9 kB] 112s Get:422 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-time-core-dev amd64 0.1.2-1 [9136 B] 112s Get:423 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-time-macros-dev amd64 0.2.16-1 [25.1 kB] 112s Get:424 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-time-dev amd64 0.3.36-2 [99.4 kB] 112s Get:425 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-postgres-types-dev amd64 0.2.6-2 [30.1 kB] 112s Get:426 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rand-xorshift-dev amd64 0.3.0-2 [10.9 kB] 112s Get:427 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-quick-error-dev amd64 2.0.1-1 [15.6 kB] 112s Get:428 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-tempfile-dev amd64 3.10.1-1 [33.7 kB] 112s Get:429 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rusty-fork-dev amd64 0.3.0-1 [20.4 kB] 112s Get:430 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-wait-timeout-dev amd64 0.2.0-1 [14.1 kB] 112s Get:431 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rusty-fork+wait-timeout-dev amd64 0.3.0-1 [1134 B] 112s Get:432 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-unarray-dev amd64 0.1.4-1 [14.6 kB] 112s Get:433 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-proptest-dev amd64 1.5.0-2 [171 kB] 112s Get:434 http://ftpmaster.internal/ubuntu plucky/universe amd64 llvm-19-runtime amd64 1:19.1.2-1ubuntu1 [554 kB] 113s Get:435 http://ftpmaster.internal/ubuntu plucky/universe amd64 llvm-runtime amd64 1:19.0-60~exp1 [5608 B] 113s Get:436 http://ftpmaster.internal/ubuntu plucky/universe amd64 llvm-19-linker-tools amd64 1:19.1.2-1ubuntu1 [1312 kB] 113s Get:437 http://ftpmaster.internal/ubuntu plucky/universe amd64 libpfm4 amd64 4.13.0+git83-g91970fe-1 [429 kB] 113s Get:438 http://ftpmaster.internal/ubuntu plucky/universe amd64 llvm-19 amd64 1:19.1.2-1ubuntu1 [17.8 MB] 114s Get:439 http://ftpmaster.internal/ubuntu plucky/universe amd64 llvm amd64 1:19.0-60~exp1 [4134 B] 114s Get:440 http://ftpmaster.internal/ubuntu plucky/universe amd64 binutils-mingw-w64-x86-64 amd64 2.43.1-4ubuntu1+12 [3637 kB] 114s Get:441 http://ftpmaster.internal/ubuntu plucky/universe amd64 binutils-mingw-w64-i686 amd64 2.43.1-4ubuntu1+12 [3314 kB] 114s Get:442 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-python3-dll-a-dev amd64 0.2.10-1 [31.6 kB] 114s Get:443 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-target-lexicon-dev amd64 0.12.14-1 [25.1 kB] 114s Get:444 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-pyo3-build-config-dev amd64 0.22.6-1 [30.8 kB] 114s Get:445 http://ftpmaster.internal/ubuntu plucky/main amd64 python3.12-dev amd64 3.12.7-3 [505 kB] 114s Get:446 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-pyo3-ffi-dev amd64 0.22.6-1build1 [62.6 kB] 114s Get:447 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-pyo3-macros-backend-dev amd64 0.22.6-1 [58.5 kB] 114s Get:448 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-pyo3-macros-dev amd64 0.22.6-1 [10.4 kB] 114s Get:449 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rust-decimal-dev amd64 1.36.0-1 [114 kB] 114s Get:450 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-unindent-dev amd64 0.2.3-1 [9186 B] 114s Get:451 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-pyo3-dev amd64 0.22.6-1 [415 kB] 114s Get:452 http://ftpmaster.internal/ubuntu plucky/universe amd64 librust-rustc-hash-dev amd64 1.1.0-1 [10.8 kB] 114s Get:453 http://ftpmaster.internal/ubuntu plucky/universe amd64 pybuild-plugin-autopkgtest all 6.20241024 [1746 B] 114s Get:454 http://ftpmaster.internal/ubuntu plucky/main amd64 python3-packaging all 24.2-1 [51.5 kB] 114s Get:455 http://ftpmaster.internal/ubuntu plucky/universe amd64 python3-pyproject-hooks all 1.2.0-1 [10.2 kB] 114s Get:456 http://ftpmaster.internal/ubuntu plucky/universe amd64 python3-toml all 0.10.2-1 [16.5 kB] 114s Get:457 http://ftpmaster.internal/ubuntu plucky/universe amd64 python3-wheel all 0.45.0-1 [57.7 kB] 114s Get:458 http://ftpmaster.internal/ubuntu plucky/universe amd64 python3-build all 1.2.2-1 [31.0 kB] 114s Get:459 http://ftpmaster.internal/ubuntu plucky/universe amd64 python3-installer all 0.7.0+dfsg1-3 [17.4 kB] 114s Get:460 http://ftpmaster.internal/ubuntu plucky/universe amd64 pybuild-plugin-pyproject all 6.20241024 [1728 B] 114s Get:461 http://ftpmaster.internal/ubuntu plucky/main amd64 python3.13 amd64 3.13.0-2 [719 kB] 114s Get:462 http://ftpmaster.internal/ubuntu plucky-proposed/main amd64 python3-all amd64 3.12.7-1 [890 B] 114s Get:463 http://ftpmaster.internal/ubuntu plucky/main amd64 python3-dateutil all 2.9.0-3 [80.2 kB] 114s Get:464 http://ftpmaster.internal/ubuntu plucky/main amd64 python3-sortedcontainers all 2.4.0-2 [27.6 kB] 114s Get:465 http://ftpmaster.internal/ubuntu plucky/universe amd64 python3-hypothesis all 6.119.3-1 [329 kB] 114s Get:466 http://ftpmaster.internal/ubuntu plucky/universe amd64 python3-iniconfig all 1.1.1-2 [6024 B] 114s Get:467 http://ftpmaster.internal/ubuntu plucky/universe amd64 python3-pluggy all 1.5.0-1 [21.0 kB] 114s Get:468 http://ftpmaster.internal/ubuntu plucky/universe amd64 python3-pytest all 8.3.3-1 [251 kB] 115s Get:469 http://ftpmaster.internal/ubuntu plucky/universe amd64 python3-regex amd64 0.1.20240724-1build1 [303 kB] 115s Get:470 http://ftpmaster.internal/ubuntu plucky/main amd64 python3-semantic-version all 2.10.0-2 [15.1 kB] 115s Get:471 http://ftpmaster.internal/ubuntu plucky/main amd64 rustc amd64 1.80.1ubuntu2 [2754 B] 115s Get:472 http://ftpmaster.internal/ubuntu plucky/main amd64 cargo amd64 1.80.1ubuntu2 [2244 B] 115s Get:473 http://ftpmaster.internal/ubuntu plucky/universe amd64 python3-setuptools-rust all 1.9.0+dfsg-2 [23.1 kB] 115s Get:474 http://ftpmaster.internal/ubuntu plucky-proposed/universe amd64 python3-tiktoken amd64 0.8.0-1build1 [839 kB] 115s Fetched 235 MB in 15s (15.7 MB/s) 115s Selecting previously unselected package libpython3.13-minimal:amd64. 116s (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 ... 75651 files and directories currently installed.) 116s Preparing to unpack .../000-libpython3.13-minimal_3.13.0-2_amd64.deb ... 116s Unpacking libpython3.13-minimal:amd64 (3.13.0-2) ... 116s Selecting previously unselected package python3.13-minimal. 116s Preparing to unpack .../001-python3.13-minimal_3.13.0-2_amd64.deb ... 116s Unpacking python3.13-minimal (3.13.0-2) ... 116s Selecting previously unselected package m4. 116s Preparing to unpack .../002-m4_1.4.19-4build1_amd64.deb ... 116s Unpacking m4 (1.4.19-4build1) ... 116s Selecting previously unselected package autoconf. 116s Preparing to unpack .../003-autoconf_2.72-3_all.deb ... 116s Unpacking autoconf (2.72-3) ... 116s Selecting previously unselected package autotools-dev. 116s Preparing to unpack .../004-autotools-dev_20220109.1_all.deb ... 116s Unpacking autotools-dev (20220109.1) ... 116s Selecting previously unselected package automake. 116s Preparing to unpack .../005-automake_1%3a1.16.5-1.3ubuntu1_all.deb ... 116s Unpacking automake (1:1.16.5-1.3ubuntu1) ... 116s Selecting previously unselected package autopoint. 116s Preparing to unpack .../006-autopoint_0.22.5-2_all.deb ... 116s Unpacking autopoint (0.22.5-2) ... 116s Selecting previously unselected package libisl23:amd64. 116s Preparing to unpack .../007-libisl23_0.27-1_amd64.deb ... 116s Unpacking libisl23:amd64 (0.27-1) ... 116s Selecting previously unselected package libmpc3:amd64. 116s Preparing to unpack .../008-libmpc3_1.3.1-1build2_amd64.deb ... 116s Unpacking libmpc3:amd64 (1.3.1-1build2) ... 116s Selecting previously unselected package cpp-14-x86-64-linux-gnu. 116s Preparing to unpack .../009-cpp-14-x86-64-linux-gnu_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking cpp-14-x86-64-linux-gnu (14.2.0-8ubuntu1) ... 116s Selecting previously unselected package cpp-14. 116s Preparing to unpack .../010-cpp-14_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking cpp-14 (14.2.0-8ubuntu1) ... 116s Selecting previously unselected package cpp-x86-64-linux-gnu. 116s Preparing to unpack .../011-cpp-x86-64-linux-gnu_4%3a14.1.0-2ubuntu1_amd64.deb ... 116s Unpacking cpp-x86-64-linux-gnu (4:14.1.0-2ubuntu1) ... 116s Selecting previously unselected package cpp. 116s Preparing to unpack .../012-cpp_4%3a14.1.0-2ubuntu1_amd64.deb ... 116s Unpacking cpp (4:14.1.0-2ubuntu1) ... 116s Selecting previously unselected package libcc1-0:amd64. 116s Preparing to unpack .../013-libcc1-0_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking libcc1-0:amd64 (14.2.0-8ubuntu1) ... 116s Selecting previously unselected package libgomp1:amd64. 116s Preparing to unpack .../014-libgomp1_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking libgomp1:amd64 (14.2.0-8ubuntu1) ... 116s Selecting previously unselected package libitm1:amd64. 116s Preparing to unpack .../015-libitm1_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking libitm1:amd64 (14.2.0-8ubuntu1) ... 116s Selecting previously unselected package libasan8:amd64. 116s Preparing to unpack .../016-libasan8_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking libasan8:amd64 (14.2.0-8ubuntu1) ... 116s Selecting previously unselected package liblsan0:amd64. 116s Preparing to unpack .../017-liblsan0_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking liblsan0:amd64 (14.2.0-8ubuntu1) ... 116s Selecting previously unselected package libtsan2:amd64. 116s Preparing to unpack .../018-libtsan2_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking libtsan2:amd64 (14.2.0-8ubuntu1) ... 116s Selecting previously unselected package libubsan1:amd64. 116s Preparing to unpack .../019-libubsan1_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking libubsan1:amd64 (14.2.0-8ubuntu1) ... 116s Selecting previously unselected package libhwasan0:amd64. 116s Preparing to unpack .../020-libhwasan0_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking libhwasan0:amd64 (14.2.0-8ubuntu1) ... 116s Selecting previously unselected package libquadmath0:amd64. 116s Preparing to unpack .../021-libquadmath0_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking libquadmath0:amd64 (14.2.0-8ubuntu1) ... 116s Selecting previously unselected package libgcc-14-dev:amd64. 116s Preparing to unpack .../022-libgcc-14-dev_14.2.0-8ubuntu1_amd64.deb ... 116s Unpacking libgcc-14-dev:amd64 (14.2.0-8ubuntu1) ... 117s Selecting previously unselected package gcc-14-x86-64-linux-gnu. 117s Preparing to unpack .../023-gcc-14-x86-64-linux-gnu_14.2.0-8ubuntu1_amd64.deb ... 117s Unpacking gcc-14-x86-64-linux-gnu (14.2.0-8ubuntu1) ... 117s Selecting previously unselected package gcc-14. 117s Preparing to unpack .../024-gcc-14_14.2.0-8ubuntu1_amd64.deb ... 117s Unpacking gcc-14 (14.2.0-8ubuntu1) ... 117s Selecting previously unselected package gcc-x86-64-linux-gnu. 117s Preparing to unpack .../025-gcc-x86-64-linux-gnu_4%3a14.1.0-2ubuntu1_amd64.deb ... 117s Unpacking gcc-x86-64-linux-gnu (4:14.1.0-2ubuntu1) ... 117s Selecting previously unselected package gcc. 117s Preparing to unpack .../026-gcc_4%3a14.1.0-2ubuntu1_amd64.deb ... 117s Unpacking gcc (4:14.1.0-2ubuntu1) ... 117s Selecting previously unselected package libstdc++-14-dev:amd64. 117s Preparing to unpack .../027-libstdc++-14-dev_14.2.0-8ubuntu1_amd64.deb ... 117s Unpacking libstdc++-14-dev:amd64 (14.2.0-8ubuntu1) ... 117s Selecting previously unselected package g++-14-x86-64-linux-gnu. 117s Preparing to unpack .../028-g++-14-x86-64-linux-gnu_14.2.0-8ubuntu1_amd64.deb ... 117s Unpacking g++-14-x86-64-linux-gnu (14.2.0-8ubuntu1) ... 117s Selecting previously unselected package g++-14. 117s Preparing to unpack .../029-g++-14_14.2.0-8ubuntu1_amd64.deb ... 117s Unpacking g++-14 (14.2.0-8ubuntu1) ... 117s Selecting previously unselected package g++-x86-64-linux-gnu. 117s Preparing to unpack .../030-g++-x86-64-linux-gnu_4%3a14.1.0-2ubuntu1_amd64.deb ... 117s Unpacking g++-x86-64-linux-gnu (4:14.1.0-2ubuntu1) ... 117s Selecting previously unselected package g++. 117s Preparing to unpack .../031-g++_4%3a14.1.0-2ubuntu1_amd64.deb ... 117s Unpacking g++ (4:14.1.0-2ubuntu1) ... 117s Selecting previously unselected package build-essential. 117s Preparing to unpack .../032-build-essential_12.10ubuntu1_amd64.deb ... 117s Unpacking build-essential (12.10ubuntu1) ... 117s Selecting previously unselected package libhttp-parser2.9:amd64. 117s Preparing to unpack .../033-libhttp-parser2.9_2.9.4-6build1_amd64.deb ... 117s Unpacking libhttp-parser2.9:amd64 (2.9.4-6build1) ... 117s Selecting previously unselected package libgit2-1.7:amd64. 117s Preparing to unpack .../034-libgit2-1.7_1.7.2+ds-1ubuntu3_amd64.deb ... 117s Unpacking libgit2-1.7:amd64 (1.7.2+ds-1ubuntu3) ... 117s Selecting previously unselected package libstd-rust-1.80:amd64. 117s Preparing to unpack .../035-libstd-rust-1.80_1.80.1+dfsg0ubuntu1-0ubuntu1_amd64.deb ... 118s Unpacking libstd-rust-1.80:amd64 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 118s Selecting previously unselected package libstd-rust-1.80-dev:amd64. 118s Preparing to unpack .../036-libstd-rust-1.80-dev_1.80.1+dfsg0ubuntu1-0ubuntu1_amd64.deb ... 118s Unpacking libstd-rust-1.80-dev:amd64 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 118s Selecting previously unselected package rustc-1.80. 118s Preparing to unpack .../037-rustc-1.80_1.80.1+dfsg0ubuntu1-0ubuntu1_amd64.deb ... 118s Unpacking rustc-1.80 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 119s Selecting previously unselected package cargo-1.80. 119s Preparing to unpack .../038-cargo-1.80_1.80.1+dfsg0ubuntu1-0ubuntu1_amd64.deb ... 119s Unpacking cargo-1.80 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 119s Selecting previously unselected package libjsoncpp25:amd64. 119s Preparing to unpack .../039-libjsoncpp25_1.9.5-6build1_amd64.deb ... 119s Unpacking libjsoncpp25:amd64 (1.9.5-6build1) ... 119s Selecting previously unselected package librhash0:amd64. 119s Preparing to unpack .../040-librhash0_1.4.3-3build1_amd64.deb ... 119s Unpacking librhash0:amd64 (1.4.3-3build1) ... 119s Selecting previously unselected package cmake-data. 119s Preparing to unpack .../041-cmake-data_3.30.3-1_all.deb ... 119s Unpacking cmake-data (3.30.3-1) ... 119s Selecting previously unselected package cmake. 119s Preparing to unpack .../042-cmake_3.30.3-1_amd64.deb ... 119s Unpacking cmake (3.30.3-1) ... 119s Selecting previously unselected package libdebhelper-perl. 119s Preparing to unpack .../043-libdebhelper-perl_13.20ubuntu1_all.deb ... 119s Unpacking libdebhelper-perl (13.20ubuntu1) ... 119s Selecting previously unselected package libtool. 119s Preparing to unpack .../044-libtool_2.4.7-8_all.deb ... 119s Unpacking libtool (2.4.7-8) ... 119s Selecting previously unselected package dh-autoreconf. 119s Preparing to unpack .../045-dh-autoreconf_20_all.deb ... 119s Unpacking dh-autoreconf (20) ... 119s Selecting previously unselected package libarchive-zip-perl. 119s Preparing to unpack .../046-libarchive-zip-perl_1.68-1_all.deb ... 119s Unpacking libarchive-zip-perl (1.68-1) ... 119s Selecting previously unselected package libfile-stripnondeterminism-perl. 119s Preparing to unpack .../047-libfile-stripnondeterminism-perl_1.14.0-1_all.deb ... 119s Unpacking libfile-stripnondeterminism-perl (1.14.0-1) ... 119s Selecting previously unselected package dh-strip-nondeterminism. 119s Preparing to unpack .../048-dh-strip-nondeterminism_1.14.0-1_all.deb ... 119s Unpacking dh-strip-nondeterminism (1.14.0-1) ... 119s Selecting previously unselected package debugedit. 119s Preparing to unpack .../049-debugedit_1%3a5.1-1_amd64.deb ... 119s Unpacking debugedit (1:5.1-1) ... 119s Selecting previously unselected package dwz. 119s Preparing to unpack .../050-dwz_0.15-1build6_amd64.deb ... 119s Unpacking dwz (0.15-1build6) ... 120s Selecting previously unselected package gettext. 120s Preparing to unpack .../051-gettext_0.22.5-2_amd64.deb ... 120s Unpacking gettext (0.22.5-2) ... 120s Selecting previously unselected package intltool-debian. 120s Preparing to unpack .../052-intltool-debian_0.35.0+20060710.6_all.deb ... 120s Unpacking intltool-debian (0.35.0+20060710.6) ... 120s Selecting previously unselected package po-debconf. 120s Preparing to unpack .../053-po-debconf_1.0.21+nmu1_all.deb ... 120s Unpacking po-debconf (1.0.21+nmu1) ... 120s Selecting previously unselected package debhelper. 120s Preparing to unpack .../054-debhelper_13.20ubuntu1_all.deb ... 120s Unpacking debhelper (13.20ubuntu1) ... 120s Selecting previously unselected package dh-python. 120s Preparing to unpack .../055-dh-python_6.20241024_all.deb ... 120s Unpacking dh-python (6.20241024) ... 120s Selecting previously unselected package fonts-dejavu-mono. 120s Preparing to unpack .../056-fonts-dejavu-mono_2.37-8_all.deb ... 120s Unpacking fonts-dejavu-mono (2.37-8) ... 120s Selecting previously unselected package fonts-dejavu-core. 120s Preparing to unpack .../057-fonts-dejavu-core_2.37-8_all.deb ... 120s Unpacking fonts-dejavu-core (2.37-8) ... 120s Selecting previously unselected package fontconfig-config. 120s Preparing to unpack .../058-fontconfig-config_2.15.0-1.1ubuntu2_amd64.deb ... 120s Unpacking fontconfig-config (2.15.0-1.1ubuntu2) ... 120s Selecting previously unselected package libbrotli-dev:amd64. 120s Preparing to unpack .../059-libbrotli-dev_1.1.0-2build3_amd64.deb ... 120s Unpacking libbrotli-dev:amd64 (1.1.0-2build3) ... 120s Selecting previously unselected package libbz2-dev:amd64. 120s Preparing to unpack .../060-libbz2-dev_1.0.8-6_amd64.deb ... 120s Unpacking libbz2-dev:amd64 (1.0.8-6) ... 120s Selecting previously unselected package libexpat1-dev:amd64. 120s Preparing to unpack .../061-libexpat1-dev_2.6.4-1_amd64.deb ... 120s Unpacking libexpat1-dev:amd64 (2.6.4-1) ... 120s Selecting previously unselected package libfontconfig1:amd64. 120s Preparing to unpack .../062-libfontconfig1_2.15.0-1.1ubuntu2_amd64.deb ... 120s Unpacking libfontconfig1:amd64 (2.15.0-1.1ubuntu2) ... 120s Selecting previously unselected package zlib1g-dev:amd64. 120s Preparing to unpack .../063-zlib1g-dev_1%3a1.3.dfsg+really1.3.1-1ubuntu1_amd64.deb ... 120s Unpacking zlib1g-dev:amd64 (1:1.3.dfsg+really1.3.1-1ubuntu1) ... 120s Selecting previously unselected package libpng-dev:amd64. 120s Preparing to unpack .../064-libpng-dev_1.6.44-2_amd64.deb ... 120s Unpacking libpng-dev:amd64 (1.6.44-2) ... 120s Selecting previously unselected package libfreetype-dev:amd64. 120s Preparing to unpack .../065-libfreetype-dev_2.13.3+dfsg-1_amd64.deb ... 120s Unpacking libfreetype-dev:amd64 (2.13.3+dfsg-1) ... 120s Selecting previously unselected package uuid-dev:amd64. 120s Preparing to unpack .../066-uuid-dev_2.40.2-1ubuntu1_amd64.deb ... 120s Unpacking uuid-dev:amd64 (2.40.2-1ubuntu1) ... 120s Selecting previously unselected package libpkgconf3:amd64. 120s Preparing to unpack .../067-libpkgconf3_1.8.1-4_amd64.deb ... 120s Unpacking libpkgconf3:amd64 (1.8.1-4) ... 120s Selecting previously unselected package pkgconf-bin. 120s Preparing to unpack .../068-pkgconf-bin_1.8.1-4_amd64.deb ... 120s Unpacking pkgconf-bin (1.8.1-4) ... 120s Selecting previously unselected package pkgconf:amd64. 120s Preparing to unpack .../069-pkgconf_1.8.1-4_amd64.deb ... 120s Unpacking pkgconf:amd64 (1.8.1-4) ... 120s Selecting previously unselected package libfontconfig-dev:amd64. 120s Preparing to unpack .../070-libfontconfig-dev_2.15.0-1.1ubuntu2_amd64.deb ... 120s Unpacking libfontconfig-dev:amd64 (2.15.0-1.1ubuntu2) ... 120s Selecting previously unselected package libpython3.12-dev:amd64. 120s Preparing to unpack .../071-libpython3.12-dev_3.12.7-3_amd64.deb ... 120s Unpacking libpython3.12-dev:amd64 (3.12.7-3) ... 120s Selecting previously unselected package libpython3-dev:amd64. 120s Preparing to unpack .../072-libpython3-dev_3.12.7-1_amd64.deb ... 120s Unpacking libpython3-dev:amd64 (3.12.7-1) ... 121s Selecting previously unselected package libpython3.13-stdlib:amd64. 121s Preparing to unpack .../073-libpython3.13-stdlib_3.13.0-2_amd64.deb ... 121s Unpacking libpython3.13-stdlib:amd64 (3.13.0-2) ... 121s Selecting previously unselected package libpython3.13:amd64. 121s Preparing to unpack .../074-libpython3.13_3.13.0-2_amd64.deb ... 121s Unpacking libpython3.13:amd64 (3.13.0-2) ... 121s Selecting previously unselected package libpython3.13-dev:amd64. 121s Preparing to unpack .../075-libpython3.13-dev_3.13.0-2_amd64.deb ... 121s Unpacking libpython3.13-dev:amd64 (3.13.0-2) ... 121s Selecting previously unselected package libpython3-all-dev:amd64. 121s Preparing to unpack .../076-libpython3-all-dev_3.12.7-1_amd64.deb ... 121s Unpacking libpython3-all-dev:amd64 (3.12.7-1) ... 121s Selecting previously unselected package librust-ab-glyph-rasterizer-dev:amd64. 121s Preparing to unpack .../077-librust-ab-glyph-rasterizer-dev_0.1.7-1_amd64.deb ... 121s Unpacking librust-ab-glyph-rasterizer-dev:amd64 (0.1.7-1) ... 121s Selecting previously unselected package librust-libm-dev:amd64. 121s Preparing to unpack .../078-librust-libm-dev_0.2.8-1_amd64.deb ... 121s Unpacking librust-libm-dev:amd64 (0.2.8-1) ... 121s Selecting previously unselected package librust-ab-glyph-rasterizer+libm-dev:amd64. 121s Preparing to unpack .../079-librust-ab-glyph-rasterizer+libm-dev_0.1.7-1_amd64.deb ... 121s Unpacking librust-ab-glyph-rasterizer+libm-dev:amd64 (0.1.7-1) ... 121s Selecting previously unselected package librust-core-maths-dev:amd64. 121s Preparing to unpack .../080-librust-core-maths-dev_0.1.0-2_amd64.deb ... 121s Unpacking librust-core-maths-dev:amd64 (0.1.0-2) ... 121s Selecting previously unselected package librust-ttf-parser-dev:amd64. 121s Preparing to unpack .../081-librust-ttf-parser-dev_0.24.1-1_amd64.deb ... 121s Unpacking librust-ttf-parser-dev:amd64 (0.24.1-1) ... 121s Selecting previously unselected package librust-owned-ttf-parser-dev:amd64. 121s Preparing to unpack .../082-librust-owned-ttf-parser-dev_0.24.0-1_amd64.deb ... 121s Unpacking librust-owned-ttf-parser-dev:amd64 (0.24.0-1) ... 121s Selecting previously unselected package librust-ab-glyph-dev:amd64. 121s Preparing to unpack .../083-librust-ab-glyph-dev_0.2.28-1_amd64.deb ... 121s Unpacking librust-ab-glyph-dev:amd64 (0.2.28-1) ... 121s Selecting previously unselected package librust-cfg-if-dev:amd64. 121s Preparing to unpack .../084-librust-cfg-if-dev_1.0.0-1_amd64.deb ... 121s Unpacking librust-cfg-if-dev:amd64 (1.0.0-1) ... 121s Selecting previously unselected package librust-cpp-demangle-dev:amd64. 121s Preparing to unpack .../085-librust-cpp-demangle-dev_0.4.0-1_amd64.deb ... 121s Unpacking librust-cpp-demangle-dev:amd64 (0.4.0-1) ... 121s Selecting previously unselected package librust-fallible-iterator-dev:amd64. 121s Preparing to unpack .../086-librust-fallible-iterator-dev_0.3.0-2_amd64.deb ... 121s Unpacking librust-fallible-iterator-dev:amd64 (0.3.0-2) ... 121s Selecting previously unselected package librust-unicode-ident-dev:amd64. 121s Preparing to unpack .../087-librust-unicode-ident-dev_1.0.13-1_amd64.deb ... 121s Unpacking librust-unicode-ident-dev:amd64 (1.0.13-1) ... 121s Selecting previously unselected package librust-proc-macro2-dev:amd64. 121s Preparing to unpack .../088-librust-proc-macro2-dev_1.0.86-1_amd64.deb ... 121s Unpacking librust-proc-macro2-dev:amd64 (1.0.86-1) ... 121s Selecting previously unselected package librust-quote-dev:amd64. 121s Preparing to unpack .../089-librust-quote-dev_1.0.37-1_amd64.deb ... 121s Unpacking librust-quote-dev:amd64 (1.0.37-1) ... 121s Selecting previously unselected package librust-syn-dev:amd64. 121s Preparing to unpack .../090-librust-syn-dev_2.0.85-1_amd64.deb ... 121s Unpacking librust-syn-dev:amd64 (2.0.85-1) ... 121s Selecting previously unselected package librust-derive-arbitrary-dev:amd64. 121s Preparing to unpack .../091-librust-derive-arbitrary-dev_1.3.2-1_amd64.deb ... 121s Unpacking librust-derive-arbitrary-dev:amd64 (1.3.2-1) ... 121s Selecting previously unselected package librust-arbitrary-dev:amd64. 121s Preparing to unpack .../092-librust-arbitrary-dev_1.3.2-1_amd64.deb ... 121s Unpacking librust-arbitrary-dev:amd64 (1.3.2-1) ... 121s Selecting previously unselected package librust-equivalent-dev:amd64. 121s Preparing to unpack .../093-librust-equivalent-dev_1.0.1-1_amd64.deb ... 121s Unpacking librust-equivalent-dev:amd64 (1.0.1-1) ... 121s Selecting previously unselected package librust-critical-section-dev:amd64. 121s Preparing to unpack .../094-librust-critical-section-dev_1.1.3-1_amd64.deb ... 121s Unpacking librust-critical-section-dev:amd64 (1.1.3-1) ... 121s Selecting previously unselected package librust-serde-derive-dev:amd64. 121s Preparing to unpack .../095-librust-serde-derive-dev_1.0.210-1_amd64.deb ... 121s Unpacking librust-serde-derive-dev:amd64 (1.0.210-1) ... 121s Selecting previously unselected package librust-serde-dev:amd64. 121s Preparing to unpack .../096-librust-serde-dev_1.0.210-2_amd64.deb ... 121s Unpacking librust-serde-dev:amd64 (1.0.210-2) ... 121s Selecting previously unselected package librust-portable-atomic-dev:amd64. 121s Preparing to unpack .../097-librust-portable-atomic-dev_1.9.0-4_amd64.deb ... 121s Unpacking librust-portable-atomic-dev:amd64 (1.9.0-4) ... 121s Selecting previously unselected package librust-libc-dev:amd64. 121s Preparing to unpack .../098-librust-libc-dev_0.2.155-1_amd64.deb ... 121s Unpacking librust-libc-dev:amd64 (0.2.155-1) ... 121s Selecting previously unselected package librust-getrandom-dev:amd64. 121s Preparing to unpack .../099-librust-getrandom-dev_0.2.12-1_amd64.deb ... 121s Unpacking librust-getrandom-dev:amd64 (0.2.12-1) ... 122s Selecting previously unselected package librust-smallvec-dev:amd64. 122s Preparing to unpack .../100-librust-smallvec-dev_1.13.2-1_amd64.deb ... 122s Unpacking librust-smallvec-dev:amd64 (1.13.2-1) ... 122s Selecting previously unselected package librust-parking-lot-core-dev:amd64. 122s Preparing to unpack .../101-librust-parking-lot-core-dev_0.9.10-1_amd64.deb ... 122s Unpacking librust-parking-lot-core-dev:amd64 (0.9.10-1) ... 122s Selecting previously unselected package librust-once-cell-dev:amd64. 122s Preparing to unpack .../102-librust-once-cell-dev_1.20.2-1_amd64.deb ... 122s Unpacking librust-once-cell-dev:amd64 (1.20.2-1) ... 122s Selecting previously unselected package librust-crunchy-dev:amd64. 122s Preparing to unpack .../103-librust-crunchy-dev_0.2.2-1_amd64.deb ... 122s Unpacking librust-crunchy-dev:amd64 (0.2.2-1) ... 122s Selecting previously unselected package librust-tiny-keccak-dev:amd64. 122s Preparing to unpack .../104-librust-tiny-keccak-dev_2.0.2-1_amd64.deb ... 122s Unpacking librust-tiny-keccak-dev:amd64 (2.0.2-1) ... 122s Selecting previously unselected package librust-const-random-macro-dev:amd64. 122s Preparing to unpack .../105-librust-const-random-macro-dev_0.1.16-2_amd64.deb ... 122s Unpacking librust-const-random-macro-dev:amd64 (0.1.16-2) ... 122s Selecting previously unselected package librust-const-random-dev:amd64. 122s Preparing to unpack .../106-librust-const-random-dev_0.1.17-2_amd64.deb ... 122s Unpacking librust-const-random-dev:amd64 (0.1.17-2) ... 122s Selecting previously unselected package librust-version-check-dev:amd64. 122s Preparing to unpack .../107-librust-version-check-dev_0.9.5-1_amd64.deb ... 122s Unpacking librust-version-check-dev:amd64 (0.9.5-1) ... 122s Selecting previously unselected package librust-byteorder-dev:amd64. 122s Preparing to unpack .../108-librust-byteorder-dev_1.5.0-1_amd64.deb ... 122s Unpacking librust-byteorder-dev:amd64 (1.5.0-1) ... 122s Selecting previously unselected package librust-zerocopy-derive-dev:amd64. 122s Preparing to unpack .../109-librust-zerocopy-derive-dev_0.7.32-2_amd64.deb ... 122s Unpacking librust-zerocopy-derive-dev:amd64 (0.7.32-2) ... 122s Selecting previously unselected package librust-zerocopy-dev:amd64. 122s Preparing to unpack .../110-librust-zerocopy-dev_0.7.32-1_amd64.deb ... 122s Unpacking librust-zerocopy-dev:amd64 (0.7.32-1) ... 122s Selecting previously unselected package librust-ahash-dev. 122s Preparing to unpack .../111-librust-ahash-dev_0.8.11-8_all.deb ... 122s Unpacking librust-ahash-dev (0.8.11-8) ... 122s Selecting previously unselected package librust-allocator-api2-dev:amd64. 122s Preparing to unpack .../112-librust-allocator-api2-dev_0.2.16-1_amd64.deb ... 122s Unpacking librust-allocator-api2-dev:amd64 (0.2.16-1) ... 122s Selecting previously unselected package librust-compiler-builtins-dev:amd64. 122s Preparing to unpack .../113-librust-compiler-builtins-dev_0.1.101-1_amd64.deb ... 122s Unpacking librust-compiler-builtins-dev:amd64 (0.1.101-1) ... 122s Selecting previously unselected package librust-either-dev:amd64. 122s Preparing to unpack .../114-librust-either-dev_1.13.0-1_amd64.deb ... 122s Unpacking librust-either-dev:amd64 (1.13.0-1) ... 122s Selecting previously unselected package librust-crossbeam-utils-dev:amd64. 122s Preparing to unpack .../115-librust-crossbeam-utils-dev_0.8.19-1_amd64.deb ... 122s Unpacking librust-crossbeam-utils-dev:amd64 (0.8.19-1) ... 122s Selecting previously unselected package librust-crossbeam-epoch-dev:amd64. 122s Preparing to unpack .../116-librust-crossbeam-epoch-dev_0.9.18-1_amd64.deb ... 122s Unpacking librust-crossbeam-epoch-dev:amd64 (0.9.18-1) ... 122s Selecting previously unselected package librust-crossbeam-epoch+std-dev:amd64. 122s Preparing to unpack .../117-librust-crossbeam-epoch+std-dev_0.9.18-1_amd64.deb ... 122s Unpacking librust-crossbeam-epoch+std-dev:amd64 (0.9.18-1) ... 122s Selecting previously unselected package librust-crossbeam-deque-dev:amd64. 122s Preparing to unpack .../118-librust-crossbeam-deque-dev_0.8.5-1_amd64.deb ... 122s Unpacking librust-crossbeam-deque-dev:amd64 (0.8.5-1) ... 122s Selecting previously unselected package librust-rayon-core-dev:amd64. 122s Preparing to unpack .../119-librust-rayon-core-dev_1.12.1-1_amd64.deb ... 122s Unpacking librust-rayon-core-dev:amd64 (1.12.1-1) ... 122s Selecting previously unselected package librust-rayon-dev:amd64. 122s Preparing to unpack .../120-librust-rayon-dev_1.10.0-1_amd64.deb ... 122s Unpacking librust-rayon-dev:amd64 (1.10.0-1) ... 122s Selecting previously unselected package librust-rustc-std-workspace-core-dev:amd64. 122s Preparing to unpack .../121-librust-rustc-std-workspace-core-dev_1.0.0-1_amd64.deb ... 122s Unpacking librust-rustc-std-workspace-core-dev:amd64 (1.0.0-1) ... 122s Selecting previously unselected package librust-hashbrown-dev:amd64. 122s Preparing to unpack .../122-librust-hashbrown-dev_0.14.5-5_amd64.deb ... 122s Unpacking librust-hashbrown-dev:amd64 (0.14.5-5) ... 122s Selecting previously unselected package librust-indexmap-dev:amd64. 122s Preparing to unpack .../123-librust-indexmap-dev_2.2.6-1_amd64.deb ... 122s Unpacking librust-indexmap-dev:amd64 (2.2.6-1) ... 122s Selecting previously unselected package librust-stable-deref-trait-dev:amd64. 122s Preparing to unpack .../124-librust-stable-deref-trait-dev_1.2.0-1_amd64.deb ... 122s Unpacking librust-stable-deref-trait-dev:amd64 (1.2.0-1) ... 122s Selecting previously unselected package librust-gimli-dev:amd64. 122s Preparing to unpack .../125-librust-gimli-dev_0.28.1-2_amd64.deb ... 122s Unpacking librust-gimli-dev:amd64 (0.28.1-2) ... 122s Selecting previously unselected package librust-memmap2-dev:amd64. 122s Preparing to unpack .../126-librust-memmap2-dev_0.9.3-1_amd64.deb ... 122s Unpacking librust-memmap2-dev:amd64 (0.9.3-1) ... 122s Selecting previously unselected package librust-crc32fast-dev:amd64. 122s Preparing to unpack .../127-librust-crc32fast-dev_1.4.2-1_amd64.deb ... 122s Unpacking librust-crc32fast-dev:amd64 (1.4.2-1) ... 122s Selecting previously unselected package pkg-config:amd64. 122s Preparing to unpack .../128-pkg-config_1.8.1-4_amd64.deb ... 122s Unpacking pkg-config:amd64 (1.8.1-4) ... 122s Selecting previously unselected package librust-pkg-config-dev:amd64. 122s Preparing to unpack .../129-librust-pkg-config-dev_0.3.27-1_amd64.deb ... 122s Unpacking librust-pkg-config-dev:amd64 (0.3.27-1) ... 122s Selecting previously unselected package librust-libz-sys-dev:amd64. 122s Preparing to unpack .../130-librust-libz-sys-dev_1.1.20-1_amd64.deb ... 122s Unpacking librust-libz-sys-dev:amd64 (1.1.20-1) ... 122s Selecting previously unselected package librust-adler-dev:amd64. 122s Preparing to unpack .../131-librust-adler-dev_1.0.2-2_amd64.deb ... 122s Unpacking librust-adler-dev:amd64 (1.0.2-2) ... 122s Selecting previously unselected package librust-miniz-oxide-dev:amd64. 122s Preparing to unpack .../132-librust-miniz-oxide-dev_0.7.1-1_amd64.deb ... 122s Unpacking librust-miniz-oxide-dev:amd64 (0.7.1-1) ... 122s Selecting previously unselected package librust-flate2-dev:amd64. 122s Preparing to unpack .../133-librust-flate2-dev_1.0.34-1_amd64.deb ... 122s Unpacking librust-flate2-dev:amd64 (1.0.34-1) ... 122s Selecting previously unselected package librust-sval-derive-dev:amd64. 122s Preparing to unpack .../134-librust-sval-derive-dev_2.6.1-2_amd64.deb ... 122s Unpacking librust-sval-derive-dev:amd64 (2.6.1-2) ... 122s Selecting previously unselected package librust-sval-dev:amd64. 122s Preparing to unpack .../135-librust-sval-dev_2.6.1-2_amd64.deb ... 122s Unpacking librust-sval-dev:amd64 (2.6.1-2) ... 122s Selecting previously unselected package librust-sval-ref-dev:amd64. 122s Preparing to unpack .../136-librust-sval-ref-dev_2.6.1-1_amd64.deb ... 122s Unpacking librust-sval-ref-dev:amd64 (2.6.1-1) ... 122s Selecting previously unselected package librust-erased-serde-dev:amd64. 122s Preparing to unpack .../137-librust-erased-serde-dev_0.3.31-1_amd64.deb ... 122s Unpacking librust-erased-serde-dev:amd64 (0.3.31-1) ... 122s Selecting previously unselected package librust-serde-fmt-dev. 122s Preparing to unpack .../138-librust-serde-fmt-dev_1.0.3-3_all.deb ... 122s Unpacking librust-serde-fmt-dev (1.0.3-3) ... 123s Selecting previously unselected package librust-syn-1-dev:amd64. 123s Preparing to unpack .../139-librust-syn-1-dev_1.0.109-2_amd64.deb ... 123s Unpacking librust-syn-1-dev:amd64 (1.0.109-2) ... 123s Selecting previously unselected package librust-no-panic-dev:amd64. 123s Preparing to unpack .../140-librust-no-panic-dev_0.1.13-1_amd64.deb ... 123s Unpacking librust-no-panic-dev:amd64 (0.1.13-1) ... 123s Selecting previously unselected package librust-itoa-dev:amd64. 123s Preparing to unpack .../141-librust-itoa-dev_1.0.9-1_amd64.deb ... 123s Unpacking librust-itoa-dev:amd64 (1.0.9-1) ... 123s Selecting previously unselected package librust-ryu-dev:amd64. 123s Preparing to unpack .../142-librust-ryu-dev_1.0.15-1_amd64.deb ... 123s Unpacking librust-ryu-dev:amd64 (1.0.15-1) ... 123s Selecting previously unselected package librust-serde-json-dev:amd64. 123s Preparing to unpack .../143-librust-serde-json-dev_1.0.128-1_amd64.deb ... 123s Unpacking librust-serde-json-dev:amd64 (1.0.128-1) ... 123s Selecting previously unselected package librust-serde-test-dev:amd64. 123s Preparing to unpack .../144-librust-serde-test-dev_1.0.171-1_amd64.deb ... 123s Unpacking librust-serde-test-dev:amd64 (1.0.171-1) ... 123s Selecting previously unselected package librust-value-bag-serde1-dev:amd64. 123s Preparing to unpack .../145-librust-value-bag-serde1-dev_1.9.0-1_amd64.deb ... 123s Unpacking librust-value-bag-serde1-dev:amd64 (1.9.0-1) ... 123s Selecting previously unselected package librust-sval-buffer-dev:amd64. 123s Preparing to unpack .../146-librust-sval-buffer-dev_2.6.1-1_amd64.deb ... 123s Unpacking librust-sval-buffer-dev:amd64 (2.6.1-1) ... 123s Selecting previously unselected package librust-sval-dynamic-dev:amd64. 123s Preparing to unpack .../147-librust-sval-dynamic-dev_2.6.1-1_amd64.deb ... 123s Unpacking librust-sval-dynamic-dev:amd64 (2.6.1-1) ... 123s Selecting previously unselected package librust-sval-fmt-dev:amd64. 123s Preparing to unpack .../148-librust-sval-fmt-dev_2.6.1-1_amd64.deb ... 123s Unpacking librust-sval-fmt-dev:amd64 (2.6.1-1) ... 123s Selecting previously unselected package librust-sval-serde-dev:amd64. 123s Preparing to unpack .../149-librust-sval-serde-dev_2.6.1-1_amd64.deb ... 123s Unpacking librust-sval-serde-dev:amd64 (2.6.1-1) ... 123s Selecting previously unselected package librust-value-bag-sval2-dev:amd64. 123s Preparing to unpack .../150-librust-value-bag-sval2-dev_1.9.0-1_amd64.deb ... 123s Unpacking librust-value-bag-sval2-dev:amd64 (1.9.0-1) ... 123s Selecting previously unselected package librust-value-bag-dev:amd64. 123s Preparing to unpack .../151-librust-value-bag-dev_1.9.0-1_amd64.deb ... 123s Unpacking librust-value-bag-dev:amd64 (1.9.0-1) ... 123s Selecting previously unselected package librust-log-dev:amd64. 123s Preparing to unpack .../152-librust-log-dev_0.4.22-1_amd64.deb ... 123s Unpacking librust-log-dev:amd64 (0.4.22-1) ... 123s Selecting previously unselected package librust-memchr-dev:amd64. 123s Preparing to unpack .../153-librust-memchr-dev_2.7.4-1_amd64.deb ... 123s Unpacking librust-memchr-dev:amd64 (2.7.4-1) ... 123s Selecting previously unselected package librust-ppv-lite86-dev:amd64. 123s Preparing to unpack .../154-librust-ppv-lite86-dev_0.2.16-1_amd64.deb ... 123s Unpacking librust-ppv-lite86-dev:amd64 (0.2.16-1) ... 123s Selecting previously unselected package librust-rand-core-dev:amd64. 123s Preparing to unpack .../155-librust-rand-core-dev_0.6.4-2_amd64.deb ... 123s Unpacking librust-rand-core-dev:amd64 (0.6.4-2) ... 123s Selecting previously unselected package librust-rand-chacha-dev:amd64. 123s Preparing to unpack .../156-librust-rand-chacha-dev_0.3.1-2_amd64.deb ... 123s Unpacking librust-rand-chacha-dev:amd64 (0.3.1-2) ... 123s Selecting previously unselected package librust-rand-core+getrandom-dev:amd64. 123s Preparing to unpack .../157-librust-rand-core+getrandom-dev_0.6.4-2_amd64.deb ... 123s Unpacking librust-rand-core+getrandom-dev:amd64 (0.6.4-2) ... 123s Selecting previously unselected package librust-rand-core+serde-dev:amd64. 123s Preparing to unpack .../158-librust-rand-core+serde-dev_0.6.4-2_amd64.deb ... 123s Unpacking librust-rand-core+serde-dev:amd64 (0.6.4-2) ... 123s Selecting previously unselected package librust-rand-core+std-dev:amd64. 123s Preparing to unpack .../159-librust-rand-core+std-dev_0.6.4-2_amd64.deb ... 123s Unpacking librust-rand-core+std-dev:amd64 (0.6.4-2) ... 123s Selecting previously unselected package librust-rand-dev:amd64. 123s Preparing to unpack .../160-librust-rand-dev_0.8.5-1_amd64.deb ... 123s Unpacking librust-rand-dev:amd64 (0.8.5-1) ... 123s Selecting previously unselected package librust-unicode-segmentation-dev:amd64. 123s Preparing to unpack .../161-librust-unicode-segmentation-dev_1.11.0-1_amd64.deb ... 123s Unpacking librust-unicode-segmentation-dev:amd64 (1.11.0-1) ... 123s Selecting previously unselected package librust-convert-case-dev:amd64. 123s Preparing to unpack .../162-librust-convert-case-dev_0.6.0-2_amd64.deb ... 123s Unpacking librust-convert-case-dev:amd64 (0.6.0-2) ... 123s Selecting previously unselected package librust-semver-dev:amd64. 123s Preparing to unpack .../163-librust-semver-dev_1.0.23-1_amd64.deb ... 123s Unpacking librust-semver-dev:amd64 (1.0.23-1) ... 123s Selecting previously unselected package librust-rustc-version-dev:amd64. 123s Preparing to unpack .../164-librust-rustc-version-dev_0.4.0-1_amd64.deb ... 123s Unpacking librust-rustc-version-dev:amd64 (0.4.0-1) ... 123s Selecting previously unselected package librust-derive-more-0.99-dev:amd64. 123s Preparing to unpack .../165-librust-derive-more-0.99-dev_0.99.18-1_amd64.deb ... 123s Unpacking librust-derive-more-0.99-dev:amd64 (0.99.18-1) ... 123s Selecting previously unselected package librust-cfg-if-0.1-dev:amd64. 123s Preparing to unpack .../166-librust-cfg-if-0.1-dev_0.1.10-2_amd64.deb ... 123s Unpacking librust-cfg-if-0.1-dev:amd64 (0.1.10-2) ... 123s Selecting previously unselected package librust-blobby-dev:amd64. 123s Preparing to unpack .../167-librust-blobby-dev_0.3.1-1_amd64.deb ... 123s Unpacking librust-blobby-dev:amd64 (0.3.1-1) ... 123s Selecting previously unselected package librust-typenum-dev:amd64. 123s Preparing to unpack .../168-librust-typenum-dev_1.17.0-2_amd64.deb ... 123s Unpacking librust-typenum-dev:amd64 (1.17.0-2) ... 123s Selecting previously unselected package librust-zeroize-derive-dev:amd64. 123s Preparing to unpack .../169-librust-zeroize-derive-dev_1.4.2-1_amd64.deb ... 123s Unpacking librust-zeroize-derive-dev:amd64 (1.4.2-1) ... 123s Selecting previously unselected package librust-zeroize-dev:amd64. 123s Preparing to unpack .../170-librust-zeroize-dev_1.8.1-1_amd64.deb ... 123s Unpacking librust-zeroize-dev:amd64 (1.8.1-1) ... 123s Selecting previously unselected package librust-generic-array-dev:amd64. 123s Preparing to unpack .../171-librust-generic-array-dev_0.14.7-1_amd64.deb ... 123s Unpacking librust-generic-array-dev:amd64 (0.14.7-1) ... 123s Selecting previously unselected package librust-block-buffer-dev:amd64. 123s Preparing to unpack .../172-librust-block-buffer-dev_0.10.2-2_amd64.deb ... 123s Unpacking librust-block-buffer-dev:amd64 (0.10.2-2) ... 123s Selecting previously unselected package librust-const-oid-dev:amd64. 123s Preparing to unpack .../173-librust-const-oid-dev_0.9.3-1_amd64.deb ... 123s Unpacking librust-const-oid-dev:amd64 (0.9.3-1) ... 123s Selecting previously unselected package librust-crypto-common-dev:amd64. 123s Preparing to unpack .../174-librust-crypto-common-dev_0.1.6-1_amd64.deb ... 123s Unpacking librust-crypto-common-dev:amd64 (0.1.6-1) ... 123s Selecting previously unselected package librust-subtle-dev:amd64. 123s Preparing to unpack .../175-librust-subtle-dev_2.6.1-1_amd64.deb ... 123s Unpacking librust-subtle-dev:amd64 (2.6.1-1) ... 123s Selecting previously unselected package librust-digest-dev:amd64. 123s Preparing to unpack .../176-librust-digest-dev_0.10.7-2_amd64.deb ... 123s Unpacking librust-digest-dev:amd64 (0.10.7-2) ... 123s Selecting previously unselected package librust-static-assertions-dev:amd64. 123s Preparing to unpack .../177-librust-static-assertions-dev_1.1.0-1_amd64.deb ... 123s Unpacking librust-static-assertions-dev:amd64 (1.1.0-1) ... 123s Selecting previously unselected package librust-twox-hash-dev:amd64. 123s Preparing to unpack .../178-librust-twox-hash-dev_1.6.3-1_amd64.deb ... 123s Unpacking librust-twox-hash-dev:amd64 (1.6.3-1) ... 123s Selecting previously unselected package librust-ruzstd-dev:amd64. 123s Preparing to unpack .../179-librust-ruzstd-dev_0.5.0-1_amd64.deb ... 123s Unpacking librust-ruzstd-dev:amd64 (0.5.0-1) ... 123s Selecting previously unselected package librust-object-dev:amd64. 123s Preparing to unpack .../180-librust-object-dev_0.32.2-1_amd64.deb ... 123s Unpacking librust-object-dev:amd64 (0.32.2-1) ... 124s Selecting previously unselected package librust-rustc-demangle-dev:amd64. 124s Preparing to unpack .../181-librust-rustc-demangle-dev_0.1.21-1_amd64.deb ... 124s Unpacking librust-rustc-demangle-dev:amd64 (0.1.21-1) ... 124s Selecting previously unselected package librust-addr2line-dev:amd64. 124s Preparing to unpack .../182-librust-addr2line-dev_0.21.0-2_amd64.deb ... 124s Unpacking librust-addr2line-dev:amd64 (0.21.0-2) ... 124s Selecting previously unselected package librust-aho-corasick-dev:amd64. 124s Preparing to unpack .../183-librust-aho-corasick-dev_1.1.3-1_amd64.deb ... 124s Unpacking librust-aho-corasick-dev:amd64 (1.1.3-1) ... 124s Selecting previously unselected package librust-bitflags-1-dev:amd64. 124s Preparing to unpack .../184-librust-bitflags-1-dev_1.3.2-5_amd64.deb ... 124s Unpacking librust-bitflags-1-dev:amd64 (1.3.2-5) ... 124s Selecting previously unselected package librust-anes-dev:amd64. 124s Preparing to unpack .../185-librust-anes-dev_0.1.6-1_amd64.deb ... 124s Unpacking librust-anes-dev:amd64 (0.1.6-1) ... 124s Selecting previously unselected package librust-anstyle-dev:amd64. 124s Preparing to unpack .../186-librust-anstyle-dev_1.0.8-1_amd64.deb ... 124s Unpacking librust-anstyle-dev:amd64 (1.0.8-1) ... 124s Selecting previously unselected package librust-arrayvec-dev:amd64. 124s Preparing to unpack .../187-librust-arrayvec-dev_0.7.4-2_amd64.deb ... 124s Unpacking librust-arrayvec-dev:amd64 (0.7.4-2) ... 124s Selecting previously unselected package librust-utf8parse-dev:amd64. 124s Preparing to unpack .../188-librust-utf8parse-dev_0.2.1-1_amd64.deb ... 124s Unpacking librust-utf8parse-dev:amd64 (0.2.1-1) ... 124s Selecting previously unselected package librust-anstyle-parse-dev:amd64. 124s Preparing to unpack .../189-librust-anstyle-parse-dev_0.2.1-1_amd64.deb ... 124s Unpacking librust-anstyle-parse-dev:amd64 (0.2.1-1) ... 124s Selecting previously unselected package librust-anstyle-query-dev:amd64. 124s Preparing to unpack .../190-librust-anstyle-query-dev_1.0.0-1_amd64.deb ... 124s Unpacking librust-anstyle-query-dev:amd64 (1.0.0-1) ... 124s Selecting previously unselected package librust-colorchoice-dev:amd64. 124s Preparing to unpack .../191-librust-colorchoice-dev_1.0.0-1_amd64.deb ... 124s Unpacking librust-colorchoice-dev:amd64 (1.0.0-1) ... 124s Selecting previously unselected package librust-anstream-dev:amd64. 124s Preparing to unpack .../192-librust-anstream-dev_0.6.15-1_amd64.deb ... 124s Unpacking librust-anstream-dev:amd64 (0.6.15-1) ... 124s Selecting previously unselected package librust-jobserver-dev:amd64. 124s Preparing to unpack .../193-librust-jobserver-dev_0.1.32-1_amd64.deb ... 124s Unpacking librust-jobserver-dev:amd64 (0.1.32-1) ... 124s Selecting previously unselected package librust-shlex-dev:amd64. 124s Preparing to unpack .../194-librust-shlex-dev_1.3.0-1_amd64.deb ... 124s Unpacking librust-shlex-dev:amd64 (1.3.0-1) ... 124s Selecting previously unselected package librust-cc-dev:amd64. 124s Preparing to unpack .../195-librust-cc-dev_1.1.14-1_amd64.deb ... 124s Unpacking librust-cc-dev:amd64 (1.1.14-1) ... 124s Selecting previously unselected package librust-backtrace-dev:amd64. 124s Preparing to unpack .../196-librust-backtrace-dev_0.3.69-2_amd64.deb ... 124s Unpacking librust-backtrace-dev:amd64 (0.3.69-2) ... 124s Selecting previously unselected package librust-anyhow-dev:amd64. 124s Preparing to unpack .../197-librust-anyhow-dev_1.0.86-1_amd64.deb ... 124s Unpacking librust-anyhow-dev:amd64 (1.0.86-1) ... 124s Selecting previously unselected package librust-bytecheck-derive-dev:amd64. 124s Preparing to unpack .../198-librust-bytecheck-derive-dev_0.6.12-1_amd64.deb ... 124s Unpacking librust-bytecheck-derive-dev:amd64 (0.6.12-1) ... 124s Selecting previously unselected package librust-ptr-meta-derive-dev:amd64. 124s Preparing to unpack .../199-librust-ptr-meta-derive-dev_0.1.4-1_amd64.deb ... 124s Unpacking librust-ptr-meta-derive-dev:amd64 (0.1.4-1) ... 124s Selecting previously unselected package librust-ptr-meta-dev:amd64. 124s Preparing to unpack .../200-librust-ptr-meta-dev_0.1.4-1_amd64.deb ... 124s Unpacking librust-ptr-meta-dev:amd64 (0.1.4-1) ... 124s Selecting previously unselected package librust-simdutf8-dev:amd64. 124s Preparing to unpack .../201-librust-simdutf8-dev_0.1.4-4_amd64.deb ... 124s Unpacking librust-simdutf8-dev:amd64 (0.1.4-4) ... 124s Selecting previously unselected package librust-bytemuck-derive-dev:amd64. 124s Preparing to unpack .../202-librust-bytemuck-derive-dev_1.5.0-2_amd64.deb ... 124s Unpacking librust-bytemuck-derive-dev:amd64 (1.5.0-2) ... 124s Selecting previously unselected package librust-bytemuck-dev:amd64. 124s Preparing to unpack .../203-librust-bytemuck-dev_1.14.0-1_amd64.deb ... 124s Unpacking librust-bytemuck-dev:amd64 (1.14.0-1) ... 124s Selecting previously unselected package librust-atomic-dev:amd64. 124s Preparing to unpack .../204-librust-atomic-dev_0.6.0-1_amd64.deb ... 124s Unpacking librust-atomic-dev:amd64 (0.6.0-1) ... 124s Selecting previously unselected package librust-md5-asm-dev:amd64. 124s Preparing to unpack .../205-librust-md5-asm-dev_0.5.0-2_amd64.deb ... 124s Unpacking librust-md5-asm-dev:amd64 (0.5.0-2) ... 124s Selecting previously unselected package librust-md-5-dev:amd64. 124s Preparing to unpack .../206-librust-md-5-dev_0.10.6-1_amd64.deb ... 124s Unpacking librust-md-5-dev:amd64 (0.10.6-1) ... 124s Selecting previously unselected package librust-cpufeatures-dev:amd64. 124s Preparing to unpack .../207-librust-cpufeatures-dev_0.2.11-1_amd64.deb ... 124s Unpacking librust-cpufeatures-dev:amd64 (0.2.11-1) ... 124s Selecting previously unselected package librust-sha1-asm-dev:amd64. 124s Preparing to unpack .../208-librust-sha1-asm-dev_0.5.1-2_amd64.deb ... 124s Unpacking librust-sha1-asm-dev:amd64 (0.5.1-2) ... 124s Selecting previously unselected package librust-sha1-dev:amd64. 124s Preparing to unpack .../209-librust-sha1-dev_0.10.6-1_amd64.deb ... 124s Unpacking librust-sha1-dev:amd64 (0.10.6-1) ... 124s Selecting previously unselected package librust-slog-dev:amd64. 124s Preparing to unpack .../210-librust-slog-dev_2.7.0-1_amd64.deb ... 124s Unpacking librust-slog-dev:amd64 (2.7.0-1) ... 124s Selecting previously unselected package librust-uuid-dev:amd64. 124s Preparing to unpack .../211-librust-uuid-dev_1.10.0-1_amd64.deb ... 124s Unpacking librust-uuid-dev:amd64 (1.10.0-1) ... 124s Selecting previously unselected package librust-bytecheck-dev:amd64. 124s Preparing to unpack .../212-librust-bytecheck-dev_0.6.12-1_amd64.deb ... 124s Unpacking librust-bytecheck-dev:amd64 (0.6.12-1) ... 124s Selecting previously unselected package librust-autocfg-dev:amd64. 124s Preparing to unpack .../213-librust-autocfg-dev_1.1.0-1_amd64.deb ... 124s Unpacking librust-autocfg-dev:amd64 (1.1.0-1) ... 124s Selecting previously unselected package librust-num-traits-dev:amd64. 124s Preparing to unpack .../214-librust-num-traits-dev_0.2.19-2_amd64.deb ... 124s Unpacking librust-num-traits-dev:amd64 (0.2.19-2) ... 124s Selecting previously unselected package librust-funty-dev:amd64. 124s Preparing to unpack .../215-librust-funty-dev_2.0.0-1_amd64.deb ... 124s Unpacking librust-funty-dev:amd64 (2.0.0-1) ... 124s Selecting previously unselected package librust-radium-dev:amd64. 124s Preparing to unpack .../216-librust-radium-dev_1.1.0-1_amd64.deb ... 124s Unpacking librust-radium-dev:amd64 (1.1.0-1) ... 124s Selecting previously unselected package librust-tap-dev:amd64. 124s Preparing to unpack .../217-librust-tap-dev_1.0.1-1_amd64.deb ... 124s Unpacking librust-tap-dev:amd64 (1.0.1-1) ... 124s Selecting previously unselected package librust-traitobject-dev:amd64. 124s Preparing to unpack .../218-librust-traitobject-dev_0.1.0-1_amd64.deb ... 124s Unpacking librust-traitobject-dev:amd64 (0.1.0-1) ... 124s Selecting previously unselected package librust-unsafe-any-dev:amd64. 124s Preparing to unpack .../219-librust-unsafe-any-dev_0.4.2-2_amd64.deb ... 124s Unpacking librust-unsafe-any-dev:amd64 (0.4.2-2) ... 124s Selecting previously unselected package librust-typemap-dev:amd64. 124s Preparing to unpack .../220-librust-typemap-dev_0.3.3-2_amd64.deb ... 124s Unpacking librust-typemap-dev:amd64 (0.3.3-2) ... 124s Selecting previously unselected package librust-wyz-dev:amd64. 124s Preparing to unpack .../221-librust-wyz-dev_0.5.1-1_amd64.deb ... 124s Unpacking librust-wyz-dev:amd64 (0.5.1-1) ... 124s Selecting previously unselected package librust-bitvec-dev:amd64. 125s Preparing to unpack .../222-librust-bitvec-dev_1.0.1-1_amd64.deb ... 125s Unpacking librust-bitvec-dev:amd64 (1.0.1-1) ... 125s Selecting previously unselected package librust-bytes-dev:amd64. 125s Preparing to unpack .../223-librust-bytes-dev_1.8.0-1_amd64.deb ... 125s Unpacking librust-bytes-dev:amd64 (1.8.0-1) ... 125s Selecting previously unselected package librust-rend-dev:amd64. 125s Preparing to unpack .../224-librust-rend-dev_0.4.0-1_amd64.deb ... 125s Unpacking librust-rend-dev:amd64 (0.4.0-1) ... 125s Selecting previously unselected package librust-rkyv-derive-dev:amd64. 125s Preparing to unpack .../225-librust-rkyv-derive-dev_0.7.44-1_amd64.deb ... 125s Unpacking librust-rkyv-derive-dev:amd64 (0.7.44-1) ... 125s Selecting previously unselected package librust-seahash-dev:amd64. 125s Preparing to unpack .../226-librust-seahash-dev_4.1.0-1_amd64.deb ... 125s Unpacking librust-seahash-dev:amd64 (4.1.0-1) ... 125s Selecting previously unselected package librust-smol-str-dev:amd64. 125s Preparing to unpack .../227-librust-smol-str-dev_0.2.0-1_amd64.deb ... 125s Unpacking librust-smol-str-dev:amd64 (0.2.0-1) ... 125s Selecting previously unselected package librust-tinyvec-dev:amd64. 125s Preparing to unpack .../228-librust-tinyvec-dev_1.6.0-2_amd64.deb ... 125s Unpacking librust-tinyvec-dev:amd64 (1.6.0-2) ... 125s Selecting previously unselected package librust-tinyvec-macros-dev:amd64. 125s Preparing to unpack .../229-librust-tinyvec-macros-dev_0.1.0-1_amd64.deb ... 125s Unpacking librust-tinyvec-macros-dev:amd64 (0.1.0-1) ... 125s Selecting previously unselected package librust-tinyvec+tinyvec-macros-dev:amd64. 125s Preparing to unpack .../230-librust-tinyvec+tinyvec-macros-dev_1.6.0-2_amd64.deb ... 125s Unpacking librust-tinyvec+tinyvec-macros-dev:amd64 (1.6.0-2) ... 125s Selecting previously unselected package librust-rkyv-dev:amd64. 125s Preparing to unpack .../231-librust-rkyv-dev_0.7.44-1_amd64.deb ... 125s Unpacking librust-rkyv-dev:amd64 (0.7.44-1) ... 125s Selecting previously unselected package librust-num-complex-dev:amd64. 125s Preparing to unpack .../232-librust-num-complex-dev_0.4.6-2_amd64.deb ... 125s Unpacking librust-num-complex-dev:amd64 (0.4.6-2) ... 125s Selecting previously unselected package librust-approx-dev:amd64. 125s Preparing to unpack .../233-librust-approx-dev_0.5.1-1_amd64.deb ... 125s Unpacking librust-approx-dev:amd64 (0.5.1-1) ... 125s Selecting previously unselected package librust-array-init-dev:amd64. 125s Preparing to unpack .../234-librust-array-init-dev_2.0.1-1_amd64.deb ... 125s Unpacking librust-array-init-dev:amd64 (2.0.1-1) ... 125s Selecting previously unselected package librust-async-attributes-dev. 125s Preparing to unpack .../235-librust-async-attributes-dev_1.1.2-6_all.deb ... 125s Unpacking librust-async-attributes-dev (1.1.2-6) ... 125s Selecting previously unselected package librust-concurrent-queue-dev:amd64. 125s Preparing to unpack .../236-librust-concurrent-queue-dev_2.5.0-4_amd64.deb ... 125s Unpacking librust-concurrent-queue-dev:amd64 (2.5.0-4) ... 125s Selecting previously unselected package librust-parking-dev:amd64. 125s Preparing to unpack .../237-librust-parking-dev_2.2.0-1_amd64.deb ... 125s Unpacking librust-parking-dev:amd64 (2.2.0-1) ... 125s Selecting previously unselected package librust-pin-project-lite-dev:amd64. 125s Preparing to unpack .../238-librust-pin-project-lite-dev_0.2.13-1_amd64.deb ... 125s Unpacking librust-pin-project-lite-dev:amd64 (0.2.13-1) ... 125s Selecting previously unselected package librust-event-listener-dev. 125s Preparing to unpack .../239-librust-event-listener-dev_5.3.1-8_all.deb ... 125s Unpacking librust-event-listener-dev (5.3.1-8) ... 125s Selecting previously unselected package librust-event-listener-strategy-dev:amd64. 125s Preparing to unpack .../240-librust-event-listener-strategy-dev_0.5.2-3_amd64.deb ... 125s Unpacking librust-event-listener-strategy-dev:amd64 (0.5.2-3) ... 125s Selecting previously unselected package librust-futures-core-dev:amd64. 125s Preparing to unpack .../241-librust-futures-core-dev_0.3.30-1_amd64.deb ... 125s Unpacking librust-futures-core-dev:amd64 (0.3.30-1) ... 125s Selecting previously unselected package librust-async-channel-dev. 125s Preparing to unpack .../242-librust-async-channel-dev_2.3.1-8_all.deb ... 125s Unpacking librust-async-channel-dev (2.3.1-8) ... 125s Selecting previously unselected package librust-async-task-dev. 125s Preparing to unpack .../243-librust-async-task-dev_4.7.1-3_all.deb ... 125s Unpacking librust-async-task-dev (4.7.1-3) ... 125s Selecting previously unselected package librust-fastrand-dev:amd64. 125s Preparing to unpack .../244-librust-fastrand-dev_2.1.1-1_amd64.deb ... 125s Unpacking librust-fastrand-dev:amd64 (2.1.1-1) ... 125s Selecting previously unselected package librust-futures-io-dev:amd64. 125s Preparing to unpack .../245-librust-futures-io-dev_0.3.31-1_amd64.deb ... 125s Unpacking librust-futures-io-dev:amd64 (0.3.31-1) ... 125s Selecting previously unselected package librust-futures-lite-dev:amd64. 125s Preparing to unpack .../246-librust-futures-lite-dev_2.3.0-2_amd64.deb ... 125s Unpacking librust-futures-lite-dev:amd64 (2.3.0-2) ... 125s Selecting previously unselected package librust-slab-dev:amd64. 125s Preparing to unpack .../247-librust-slab-dev_0.4.9-1_amd64.deb ... 125s Unpacking librust-slab-dev:amd64 (0.4.9-1) ... 125s Selecting previously unselected package librust-async-executor-dev. 125s Preparing to unpack .../248-librust-async-executor-dev_1.13.1-1_all.deb ... 125s Unpacking librust-async-executor-dev (1.13.1-1) ... 125s Selecting previously unselected package librust-async-lock-dev. 125s Preparing to unpack .../249-librust-async-lock-dev_3.4.0-4_all.deb ... 125s Unpacking librust-async-lock-dev (3.4.0-4) ... 125s Selecting previously unselected package librust-atomic-waker-dev:amd64. 125s Preparing to unpack .../250-librust-atomic-waker-dev_1.1.2-1_amd64.deb ... 125s Unpacking librust-atomic-waker-dev:amd64 (1.1.2-1) ... 125s Selecting previously unselected package librust-tracing-attributes-dev:amd64. 125s Preparing to unpack .../251-librust-tracing-attributes-dev_0.1.27-1_amd64.deb ... 125s Unpacking librust-tracing-attributes-dev:amd64 (0.1.27-1) ... 125s Selecting previously unselected package librust-valuable-derive-dev:amd64. 125s Preparing to unpack .../252-librust-valuable-derive-dev_0.1.0-1_amd64.deb ... 125s Unpacking librust-valuable-derive-dev:amd64 (0.1.0-1) ... 125s Selecting previously unselected package librust-valuable-dev:amd64. 125s Preparing to unpack .../253-librust-valuable-dev_0.1.0-4_amd64.deb ... 125s Unpacking librust-valuable-dev:amd64 (0.1.0-4) ... 125s Selecting previously unselected package librust-tracing-core-dev:amd64. 125s Preparing to unpack .../254-librust-tracing-core-dev_0.1.32-1_amd64.deb ... 125s Unpacking librust-tracing-core-dev:amd64 (0.1.32-1) ... 125s Selecting previously unselected package librust-tracing-dev:amd64. 125s Preparing to unpack .../255-librust-tracing-dev_0.1.40-1_amd64.deb ... 125s Unpacking librust-tracing-dev:amd64 (0.1.40-1) ... 125s Selecting previously unselected package librust-blocking-dev. 125s Preparing to unpack .../256-librust-blocking-dev_1.6.1-5_all.deb ... 125s Unpacking librust-blocking-dev (1.6.1-5) ... 125s Selecting previously unselected package librust-async-fs-dev. 125s Preparing to unpack .../257-librust-async-fs-dev_2.1.2-4_all.deb ... 125s Unpacking librust-async-fs-dev (2.1.2-4) ... 125s Selecting previously unselected package librust-bitflags-dev:amd64. 125s Preparing to unpack .../258-librust-bitflags-dev_2.6.0-1_amd64.deb ... 125s Unpacking librust-bitflags-dev:amd64 (2.6.0-1) ... 125s Selecting previously unselected package librust-compiler-builtins+core-dev:amd64. 125s Preparing to unpack .../259-librust-compiler-builtins+core-dev_0.1.101-1_amd64.deb ... 125s Unpacking librust-compiler-builtins+core-dev:amd64 (0.1.101-1) ... 125s Selecting previously unselected package librust-compiler-builtins+rustc-dep-of-std-dev:amd64. 126s Preparing to unpack .../260-librust-compiler-builtins+rustc-dep-of-std-dev_0.1.101-1_amd64.deb ... 126s Unpacking librust-compiler-builtins+rustc-dep-of-std-dev:amd64 (0.1.101-1) ... 126s Selecting previously unselected package librust-errno-dev:amd64. 126s Preparing to unpack .../261-librust-errno-dev_0.3.8-1_amd64.deb ... 126s Unpacking librust-errno-dev:amd64 (0.3.8-1) ... 126s Selecting previously unselected package librust-linux-raw-sys-dev:amd64. 126s Preparing to unpack .../262-librust-linux-raw-sys-dev_0.4.14-1_amd64.deb ... 126s Unpacking librust-linux-raw-sys-dev:amd64 (0.4.14-1) ... 126s Selecting previously unselected package librust-rustix-dev:amd64. 126s Preparing to unpack .../263-librust-rustix-dev_0.38.32-1_amd64.deb ... 126s Unpacking librust-rustix-dev:amd64 (0.38.32-1) ... 126s Selecting previously unselected package librust-polling-dev:amd64. 126s Preparing to unpack .../264-librust-polling-dev_3.4.0-1_amd64.deb ... 126s Unpacking librust-polling-dev:amd64 (3.4.0-1) ... 126s Selecting previously unselected package librust-async-io-dev:amd64. 126s Preparing to unpack .../265-librust-async-io-dev_2.3.3-4_amd64.deb ... 126s Unpacking librust-async-io-dev:amd64 (2.3.3-4) ... 126s Selecting previously unselected package librust-mio-dev:amd64. 126s Preparing to unpack .../266-librust-mio-dev_1.0.2-2_amd64.deb ... 126s Unpacking librust-mio-dev:amd64 (1.0.2-2) ... 126s Selecting previously unselected package librust-owning-ref-dev:amd64. 126s Preparing to unpack .../267-librust-owning-ref-dev_0.4.1-1_amd64.deb ... 126s Unpacking librust-owning-ref-dev:amd64 (0.4.1-1) ... 126s Selecting previously unselected package librust-scopeguard-dev:amd64. 126s Preparing to unpack .../268-librust-scopeguard-dev_1.2.0-1_amd64.deb ... 126s Unpacking librust-scopeguard-dev:amd64 (1.2.0-1) ... 126s Selecting previously unselected package librust-lock-api-dev:amd64. 126s Preparing to unpack .../269-librust-lock-api-dev_0.4.12-1_amd64.deb ... 126s Unpacking librust-lock-api-dev:amd64 (0.4.12-1) ... 126s Selecting previously unselected package librust-parking-lot-dev:amd64. 126s Preparing to unpack .../270-librust-parking-lot-dev_0.12.3-1_amd64.deb ... 126s Unpacking librust-parking-lot-dev:amd64 (0.12.3-1) ... 126s Selecting previously unselected package librust-signal-hook-registry-dev:amd64. 126s Preparing to unpack .../271-librust-signal-hook-registry-dev_1.4.0-1_amd64.deb ... 126s Unpacking librust-signal-hook-registry-dev:amd64 (1.4.0-1) ... 126s Selecting previously unselected package librust-socket2-dev:amd64. 126s Preparing to unpack .../272-librust-socket2-dev_0.5.7-1_amd64.deb ... 126s Unpacking librust-socket2-dev:amd64 (0.5.7-1) ... 126s Selecting previously unselected package librust-tokio-macros-dev:amd64. 126s Preparing to unpack .../273-librust-tokio-macros-dev_2.4.0-2_amd64.deb ... 126s Unpacking librust-tokio-macros-dev:amd64 (2.4.0-2) ... 126s Selecting previously unselected package librust-tokio-dev:amd64. 126s Preparing to unpack .../274-librust-tokio-dev_1.39.3-3_amd64.deb ... 126s Unpacking librust-tokio-dev:amd64 (1.39.3-3) ... 126s Selecting previously unselected package librust-async-global-executor-dev:amd64. 126s Preparing to unpack .../275-librust-async-global-executor-dev_2.4.1-5_amd64.deb ... 126s Unpacking librust-async-global-executor-dev:amd64 (2.4.1-5) ... 126s Selecting previously unselected package librust-async-net-dev. 126s Preparing to unpack .../276-librust-async-net-dev_2.0.0-4_all.deb ... 126s Unpacking librust-async-net-dev (2.0.0-4) ... 126s Selecting previously unselected package librust-async-signal-dev:amd64. 126s Preparing to unpack .../277-librust-async-signal-dev_0.2.10-1_amd64.deb ... 126s Unpacking librust-async-signal-dev:amd64 (0.2.10-1) ... 126s Selecting previously unselected package librust-async-process-dev. 126s Preparing to unpack .../278-librust-async-process-dev_2.3.0-1_all.deb ... 126s Unpacking librust-async-process-dev (2.3.0-1) ... 126s Selecting previously unselected package librust-kv-log-macro-dev. 126s Preparing to unpack .../279-librust-kv-log-macro-dev_1.0.8-4_all.deb ... 126s Unpacking librust-kv-log-macro-dev (1.0.8-4) ... 126s Selecting previously unselected package librust-pin-utils-dev:amd64. 126s Preparing to unpack .../280-librust-pin-utils-dev_0.1.0-1_amd64.deb ... 126s Unpacking librust-pin-utils-dev:amd64 (0.1.0-1) ... 126s Selecting previously unselected package librust-async-std-dev. 126s Preparing to unpack .../281-librust-async-std-dev_1.13.0-1_all.deb ... 126s Unpacking librust-async-std-dev (1.13.0-1) ... 126s Selecting previously unselected package librust-base64-dev:amd64. 126s Preparing to unpack .../282-librust-base64-dev_0.21.7-1_amd64.deb ... 126s Unpacking librust-base64-dev:amd64 (0.21.7-1) ... 126s Selecting previously unselected package librust-bit-vec-dev:amd64. 126s Preparing to unpack .../283-librust-bit-vec-dev_0.6.3-1_amd64.deb ... 126s Unpacking librust-bit-vec-dev:amd64 (0.6.3-1) ... 126s Selecting previously unselected package librust-bit-set-dev:amd64. 126s Preparing to unpack .../284-librust-bit-set-dev_0.5.2-1_amd64.deb ... 126s Unpacking librust-bit-set-dev:amd64 (0.5.2-1) ... 126s Selecting previously unselected package librust-bit-set+std-dev:amd64. 126s Preparing to unpack .../285-librust-bit-set+std-dev_0.5.2-1_amd64.deb ... 126s Unpacking librust-bit-set+std-dev:amd64 (0.5.2-1) ... 126s Selecting previously unselected package librust-regex-syntax-dev:amd64. 126s Preparing to unpack .../286-librust-regex-syntax-dev_0.8.2-1_amd64.deb ... 126s Unpacking librust-regex-syntax-dev:amd64 (0.8.2-1) ... 126s Selecting previously unselected package librust-regex-automata-dev:amd64. 126s Preparing to unpack .../287-librust-regex-automata-dev_0.4.7-1_amd64.deb ... 126s Unpacking librust-regex-automata-dev:amd64 (0.4.7-1) ... 126s Selecting previously unselected package librust-bstr-dev:amd64. 126s Preparing to unpack .../288-librust-bstr-dev_1.7.0-2build1_amd64.deb ... 126s Unpacking librust-bstr-dev:amd64 (1.7.0-2build1) ... 126s Selecting previously unselected package librust-bumpalo-dev:amd64. 126s Preparing to unpack .../289-librust-bumpalo-dev_3.16.0-1_amd64.deb ... 126s Unpacking librust-bumpalo-dev:amd64 (3.16.0-1) ... 126s Selecting previously unselected package librust-cast-dev:amd64. 126s Preparing to unpack .../290-librust-cast-dev_0.3.0-1_amd64.deb ... 126s Unpacking librust-cast-dev:amd64 (0.3.0-1) ... 127s Selecting previously unselected package librust-iana-time-zone-dev:amd64. 127s Preparing to unpack .../291-librust-iana-time-zone-dev_0.1.60-1_amd64.deb ... 127s Unpacking librust-iana-time-zone-dev:amd64 (0.1.60-1) ... 127s Selecting previously unselected package librust-wasm-bindgen-shared-dev:amd64. 127s Preparing to unpack .../292-librust-wasm-bindgen-shared-dev_0.2.87-1_amd64.deb ... 127s Unpacking librust-wasm-bindgen-shared-dev:amd64 (0.2.87-1) ... 127s Selecting previously unselected package librust-wasm-bindgen-backend-dev:amd64. 127s Preparing to unpack .../293-librust-wasm-bindgen-backend-dev_0.2.87-1_amd64.deb ... 127s Unpacking librust-wasm-bindgen-backend-dev:amd64 (0.2.87-1) ... 127s Selecting previously unselected package librust-wasm-bindgen-macro-support-dev:amd64. 127s Preparing to unpack .../294-librust-wasm-bindgen-macro-support-dev_0.2.87-1_amd64.deb ... 127s Unpacking librust-wasm-bindgen-macro-support-dev:amd64 (0.2.87-1) ... 127s Selecting previously unselected package librust-wasm-bindgen-macro-dev:amd64. 127s Preparing to unpack .../295-librust-wasm-bindgen-macro-dev_0.2.87-1_amd64.deb ... 127s Unpacking librust-wasm-bindgen-macro-dev:amd64 (0.2.87-1) ... 127s Selecting previously unselected package librust-wasm-bindgen-dev:amd64. 127s Preparing to unpack .../296-librust-wasm-bindgen-dev_0.2.87-1_amd64.deb ... 127s Unpacking librust-wasm-bindgen-dev:amd64 (0.2.87-1) ... 127s Selecting previously unselected package librust-wasm-bindgen-macro-support+spans-dev:amd64. 127s Preparing to unpack .../297-librust-wasm-bindgen-macro-support+spans-dev_0.2.87-1_amd64.deb ... 127s Unpacking librust-wasm-bindgen-macro-support+spans-dev:amd64 (0.2.87-1) ... 127s Selecting previously unselected package librust-wasm-bindgen-macro+spans-dev:amd64. 127s Preparing to unpack .../298-librust-wasm-bindgen-macro+spans-dev_0.2.87-1_amd64.deb ... 127s Unpacking librust-wasm-bindgen-macro+spans-dev:amd64 (0.2.87-1) ... 127s Selecting previously unselected package librust-wasm-bindgen+spans-dev:amd64. 127s Preparing to unpack .../299-librust-wasm-bindgen+spans-dev_0.2.87-1_amd64.deb ... 127s Unpacking librust-wasm-bindgen+spans-dev:amd64 (0.2.87-1) ... 127s Selecting previously unselected package librust-wasm-bindgen+default-dev:amd64. 127s Preparing to unpack .../300-librust-wasm-bindgen+default-dev_0.2.87-1_amd64.deb ... 127s Unpacking librust-wasm-bindgen+default-dev:amd64 (0.2.87-1) ... 127s Selecting previously unselected package librust-js-sys-dev:amd64. 127s Preparing to unpack .../301-librust-js-sys-dev_0.3.64-1_amd64.deb ... 127s Unpacking librust-js-sys-dev:amd64 (0.3.64-1) ... 127s Selecting previously unselected package librust-pure-rust-locales-dev:amd64. 127s Preparing to unpack .../302-librust-pure-rust-locales-dev_0.8.1-1_amd64.deb ... 127s Unpacking librust-pure-rust-locales-dev:amd64 (0.8.1-1) ... 127s Selecting previously unselected package librust-chrono-dev:amd64. 127s Preparing to unpack .../303-librust-chrono-dev_0.4.38-2_amd64.deb ... 127s Unpacking librust-chrono-dev:amd64 (0.4.38-2) ... 127s Selecting previously unselected package librust-regex-dev:amd64. 127s Preparing to unpack .../304-librust-regex-dev_1.10.6-1_amd64.deb ... 127s Unpacking librust-regex-dev:amd64 (1.10.6-1) ... 127s Selecting previously unselected package librust-parse-zoneinfo-dev:amd64. 127s Preparing to unpack .../305-librust-parse-zoneinfo-dev_0.3.0-1_amd64.deb ... 127s Unpacking librust-parse-zoneinfo-dev:amd64 (0.3.0-1) ... 127s Selecting previously unselected package librust-siphasher-dev:amd64. 127s Preparing to unpack .../306-librust-siphasher-dev_0.3.10-1_amd64.deb ... 127s Unpacking librust-siphasher-dev:amd64 (0.3.10-1) ... 127s Selecting previously unselected package librust-phf-shared-dev:amd64. 127s Preparing to unpack .../307-librust-phf-shared-dev_0.11.2-1_amd64.deb ... 127s Unpacking librust-phf-shared-dev:amd64 (0.11.2-1) ... 127s Selecting previously unselected package librust-phf-dev:amd64. 127s Preparing to unpack .../308-librust-phf-dev_0.11.2-1_amd64.deb ... 127s Unpacking librust-phf-dev:amd64 (0.11.2-1) ... 127s Selecting previously unselected package librust-uncased-dev:amd64. 127s Preparing to unpack .../309-librust-uncased-dev_0.9.6-2_amd64.deb ... 127s Unpacking librust-uncased-dev:amd64 (0.9.6-2) ... 127s Selecting previously unselected package librust-phf-shared+uncased-dev:amd64. 127s Preparing to unpack .../310-librust-phf-shared+uncased-dev_0.11.2-1_amd64.deb ... 127s Unpacking librust-phf-shared+uncased-dev:amd64 (0.11.2-1) ... 127s Selecting previously unselected package librust-phf+uncased-dev:amd64. 127s Preparing to unpack .../311-librust-phf+uncased-dev_0.11.2-1_amd64.deb ... 127s Unpacking librust-phf+uncased-dev:amd64 (0.11.2-1) ... 127s Selecting previously unselected package librust-ciborium-io-dev:amd64. 127s Preparing to unpack .../312-librust-ciborium-io-dev_0.2.2-1_amd64.deb ... 127s Unpacking librust-ciborium-io-dev:amd64 (0.2.2-1) ... 127s Selecting previously unselected package librust-half-dev:amd64. 127s Preparing to unpack .../313-librust-half-dev_1.8.2-4_amd64.deb ... 127s Unpacking librust-half-dev:amd64 (1.8.2-4) ... 127s Selecting previously unselected package librust-ciborium-ll-dev:amd64. 127s Preparing to unpack .../314-librust-ciborium-ll-dev_0.2.2-1_amd64.deb ... 127s Unpacking librust-ciborium-ll-dev:amd64 (0.2.2-1) ... 127s Selecting previously unselected package librust-ciborium-dev:amd64. 127s Preparing to unpack .../315-librust-ciborium-dev_0.2.2-2_amd64.deb ... 127s Unpacking librust-ciborium-dev:amd64 (0.2.2-2) ... 127s Selecting previously unselected package librust-clap-lex-dev:amd64. 127s Preparing to unpack .../316-librust-clap-lex-dev_0.7.2-2_amd64.deb ... 127s Unpacking librust-clap-lex-dev:amd64 (0.7.2-2) ... 127s Selecting previously unselected package librust-strsim-dev:amd64. 127s Preparing to unpack .../317-librust-strsim-dev_0.11.1-1_amd64.deb ... 127s Unpacking librust-strsim-dev:amd64 (0.11.1-1) ... 127s Selecting previously unselected package librust-terminal-size-dev:amd64. 127s Preparing to unpack .../318-librust-terminal-size-dev_0.3.0-2_amd64.deb ... 127s Unpacking librust-terminal-size-dev:amd64 (0.3.0-2) ... 127s Selecting previously unselected package librust-unicase-dev:amd64. 127s Preparing to unpack .../319-librust-unicase-dev_2.7.0-1_amd64.deb ... 127s Unpacking librust-unicase-dev:amd64 (2.7.0-1) ... 127s Selecting previously unselected package librust-unicode-width-dev:amd64. 127s Preparing to unpack .../320-librust-unicode-width-dev_0.1.14-1_amd64.deb ... 127s Unpacking librust-unicode-width-dev:amd64 (0.1.14-1) ... 127s Selecting previously unselected package librust-clap-builder-dev:amd64. 127s Preparing to unpack .../321-librust-clap-builder-dev_4.5.15-2_amd64.deb ... 127s Unpacking librust-clap-builder-dev:amd64 (4.5.15-2) ... 127s Selecting previously unselected package librust-heck-dev:amd64. 127s Preparing to unpack .../322-librust-heck-dev_0.4.1-1_amd64.deb ... 127s Unpacking librust-heck-dev:amd64 (0.4.1-1) ... 127s Selecting previously unselected package librust-clap-derive-dev:amd64. 127s Preparing to unpack .../323-librust-clap-derive-dev_4.5.13-2_amd64.deb ... 127s Unpacking librust-clap-derive-dev:amd64 (4.5.13-2) ... 127s Selecting previously unselected package librust-clap-dev:amd64. 127s Preparing to unpack .../324-librust-clap-dev_4.5.16-1_amd64.deb ... 127s Unpacking librust-clap-dev:amd64 (4.5.16-1) ... 128s Selecting previously unselected package librust-csv-core-dev:amd64. 128s Preparing to unpack .../325-librust-csv-core-dev_0.1.11-1_amd64.deb ... 128s Unpacking librust-csv-core-dev:amd64 (0.1.11-1) ... 128s Selecting previously unselected package librust-csv-dev:amd64. 128s Preparing to unpack .../326-librust-csv-dev_1.3.0-1_amd64.deb ... 128s Unpacking librust-csv-dev:amd64 (1.3.0-1) ... 128s Selecting previously unselected package librust-futures-sink-dev:amd64. 128s Preparing to unpack .../327-librust-futures-sink-dev_0.3.31-1_amd64.deb ... 128s Unpacking librust-futures-sink-dev:amd64 (0.3.31-1) ... 128s Selecting previously unselected package librust-futures-channel-dev:amd64. 128s Preparing to unpack .../328-librust-futures-channel-dev_0.3.30-1_amd64.deb ... 128s Unpacking librust-futures-channel-dev:amd64 (0.3.30-1) ... 128s Selecting previously unselected package librust-futures-task-dev:amd64. 128s Preparing to unpack .../329-librust-futures-task-dev_0.3.30-1_amd64.deb ... 128s Unpacking librust-futures-task-dev:amd64 (0.3.30-1) ... 128s Selecting previously unselected package librust-futures-macro-dev:amd64. 128s Preparing to unpack .../330-librust-futures-macro-dev_0.3.30-1_amd64.deb ... 128s Unpacking librust-futures-macro-dev:amd64 (0.3.30-1) ... 128s Selecting previously unselected package librust-futures-util-dev:amd64. 128s Preparing to unpack .../331-librust-futures-util-dev_0.3.30-2_amd64.deb ... 128s Unpacking librust-futures-util-dev:amd64 (0.3.30-2) ... 128s Selecting previously unselected package librust-num-cpus-dev:amd64. 128s Preparing to unpack .../332-librust-num-cpus-dev_1.16.0-1_amd64.deb ... 128s Unpacking librust-num-cpus-dev:amd64 (1.16.0-1) ... 128s Selecting previously unselected package librust-futures-executor-dev:amd64. 128s Preparing to unpack .../333-librust-futures-executor-dev_0.3.30-1_amd64.deb ... 128s Unpacking librust-futures-executor-dev:amd64 (0.3.30-1) ... 128s Selecting previously unselected package librust-futures-dev:amd64. 128s Preparing to unpack .../334-librust-futures-dev_0.3.30-2_amd64.deb ... 128s Unpacking librust-futures-dev:amd64 (0.3.30-2) ... 128s Selecting previously unselected package librust-is-terminal-dev:amd64. 128s Preparing to unpack .../335-librust-is-terminal-dev_0.4.13-1_amd64.deb ... 128s Unpacking librust-is-terminal-dev:amd64 (0.4.13-1) ... 128s Selecting previously unselected package librust-itertools-dev:amd64. 128s Preparing to unpack .../336-librust-itertools-dev_0.10.5-1_amd64.deb ... 128s Unpacking librust-itertools-dev:amd64 (0.10.5-1) ... 128s Selecting previously unselected package librust-oorandom-dev:amd64. 128s Preparing to unpack .../337-librust-oorandom-dev_11.1.3-1_amd64.deb ... 128s Unpacking librust-oorandom-dev:amd64 (11.1.3-1) ... 128s Selecting previously unselected package librust-winapi-i686-pc-windows-gnu-dev:amd64. 128s Preparing to unpack .../338-librust-winapi-i686-pc-windows-gnu-dev_0.4.0-1_amd64.deb ... 128s Unpacking librust-winapi-i686-pc-windows-gnu-dev:amd64 (0.4.0-1) ... 128s Selecting previously unselected package librust-winapi-x86-64-pc-windows-gnu-dev:amd64. 128s Preparing to unpack .../339-librust-winapi-x86-64-pc-windows-gnu-dev_0.4.0-1_amd64.deb ... 128s Unpacking librust-winapi-x86-64-pc-windows-gnu-dev:amd64 (0.4.0-1) ... 128s Selecting previously unselected package librust-winapi-dev:amd64. 128s Preparing to unpack .../340-librust-winapi-dev_0.3.9-1_amd64.deb ... 128s Unpacking librust-winapi-dev:amd64 (0.3.9-1) ... 128s Selecting previously unselected package librust-dirs-sys-next-dev:amd64. 128s Preparing to unpack .../341-librust-dirs-sys-next-dev_0.1.1-1_amd64.deb ... 128s Unpacking librust-dirs-sys-next-dev:amd64 (0.1.1-1) ... 128s Selecting previously unselected package librust-dirs-next-dev:amd64. 128s Preparing to unpack .../342-librust-dirs-next-dev_2.0.0-1_amd64.deb ... 128s Unpacking librust-dirs-next-dev:amd64 (2.0.0-1) ... 128s Selecting previously unselected package librust-float-ord-dev:amd64. 128s Preparing to unpack .../343-librust-float-ord-dev_0.3.2-1_amd64.deb ... 128s Unpacking librust-float-ord-dev:amd64 (0.3.2-1) ... 128s Selecting previously unselected package librust-cmake-dev:amd64. 128s Preparing to unpack .../344-librust-cmake-dev_0.1.45-1_amd64.deb ... 128s Unpacking librust-cmake-dev:amd64 (0.1.45-1) ... 128s Selecting previously unselected package librust-freetype-sys-dev:amd64. 128s Preparing to unpack .../345-librust-freetype-sys-dev_0.13.1-1_amd64.deb ... 128s Unpacking librust-freetype-sys-dev:amd64 (0.13.1-1) ... 128s Selecting previously unselected package librust-freetype-dev:amd64. 128s Preparing to unpack .../346-librust-freetype-dev_0.7.0-4_amd64.deb ... 128s Unpacking librust-freetype-dev:amd64 (0.7.0-4) ... 128s Selecting previously unselected package librust-spin-dev:amd64. 128s Preparing to unpack .../347-librust-spin-dev_0.9.8-4_amd64.deb ... 128s Unpacking librust-spin-dev:amd64 (0.9.8-4) ... 128s Selecting previously unselected package librust-lazy-static-dev:amd64. 128s Preparing to unpack .../348-librust-lazy-static-dev_1.5.0-1_amd64.deb ... 128s Unpacking librust-lazy-static-dev:amd64 (1.5.0-1) ... 128s Selecting previously unselected package librust-pathfinder-simd-dev:amd64. 128s Preparing to unpack .../349-librust-pathfinder-simd-dev_0.5.2-1_amd64.deb ... 128s Unpacking librust-pathfinder-simd-dev:amd64 (0.5.2-1) ... 128s Selecting previously unselected package librust-pathfinder-geometry-dev:amd64. 128s Preparing to unpack .../350-librust-pathfinder-geometry-dev_0.5.1-1_amd64.deb ... 128s Unpacking librust-pathfinder-geometry-dev:amd64 (0.5.1-1) ... 128s Selecting previously unselected package librust-winapi-util-dev:amd64. 128s Preparing to unpack .../351-librust-winapi-util-dev_0.1.6-1_amd64.deb ... 128s Unpacking librust-winapi-util-dev:amd64 (0.1.6-1) ... 128s Selecting previously unselected package librust-same-file-dev:amd64. 128s Preparing to unpack .../352-librust-same-file-dev_1.0.6-1_amd64.deb ... 128s Unpacking librust-same-file-dev:amd64 (1.0.6-1) ... 128s Selecting previously unselected package librust-walkdir-dev:amd64. 128s Preparing to unpack .../353-librust-walkdir-dev_2.5.0-1_amd64.deb ... 128s Unpacking librust-walkdir-dev:amd64 (2.5.0-1) ... 128s Selecting previously unselected package librust-const-cstr-dev:amd64. 128s Preparing to unpack .../354-librust-const-cstr-dev_0.3.0-1_amd64.deb ... 128s Unpacking librust-const-cstr-dev:amd64 (0.3.0-1) ... 128s Selecting previously unselected package librust-libloading-dev:amd64. 128s Preparing to unpack .../355-librust-libloading-dev_0.8.5-1_amd64.deb ... 128s Unpacking librust-libloading-dev:amd64 (0.8.5-1) ... 128s Selecting previously unselected package librust-dlib-dev:amd64. 128s Preparing to unpack .../356-librust-dlib-dev_0.5.2-2_amd64.deb ... 128s Unpacking librust-dlib-dev:amd64 (0.5.2-2) ... 128s Selecting previously unselected package librust-yeslogic-fontconfig-sys-dev:amd64. 128s Preparing to unpack .../357-librust-yeslogic-fontconfig-sys-dev_3.0.1-1_amd64.deb ... 128s Unpacking librust-yeslogic-fontconfig-sys-dev:amd64 (3.0.1-1) ... 128s Selecting previously unselected package librust-font-kit-dev:amd64. 129s Preparing to unpack .../358-librust-font-kit-dev_0.11.0-2_amd64.deb ... 129s Unpacking librust-font-kit-dev:amd64 (0.11.0-2) ... 129s Selecting previously unselected package librust-color-quant-dev:amd64. 129s Preparing to unpack .../359-librust-color-quant-dev_1.1.0-1_amd64.deb ... 129s Unpacking librust-color-quant-dev:amd64 (1.1.0-1) ... 129s Selecting previously unselected package librust-weezl-dev:amd64. 129s Preparing to unpack .../360-librust-weezl-dev_0.1.5-1_amd64.deb ... 129s Unpacking librust-weezl-dev:amd64 (0.1.5-1) ... 129s Selecting previously unselected package librust-gif-dev:amd64. 129s Preparing to unpack .../361-librust-gif-dev_0.11.3-1_amd64.deb ... 129s Unpacking librust-gif-dev:amd64 (0.11.3-1) ... 129s Selecting previously unselected package librust-jpeg-decoder-dev:amd64. 129s Preparing to unpack .../362-librust-jpeg-decoder-dev_0.3.0-1_amd64.deb ... 129s Unpacking librust-jpeg-decoder-dev:amd64 (0.3.0-1) ... 129s Selecting previously unselected package librust-num-integer-dev:amd64. 129s Preparing to unpack .../363-librust-num-integer-dev_0.1.46-1_amd64.deb ... 129s Unpacking librust-num-integer-dev:amd64 (0.1.46-1) ... 129s Selecting previously unselected package librust-humantime-dev:amd64. 129s Preparing to unpack .../364-librust-humantime-dev_2.1.0-1_amd64.deb ... 129s Unpacking librust-humantime-dev:amd64 (2.1.0-1) ... 129s Selecting previously unselected package librust-termcolor-dev:amd64. 129s Preparing to unpack .../365-librust-termcolor-dev_1.4.1-1_amd64.deb ... 129s Unpacking librust-termcolor-dev:amd64 (1.4.1-1) ... 129s Selecting previously unselected package librust-env-logger-dev:amd64. 129s Preparing to unpack .../366-librust-env-logger-dev_0.10.2-2_amd64.deb ... 129s Unpacking librust-env-logger-dev:amd64 (0.10.2-2) ... 129s Selecting previously unselected package librust-quickcheck-dev:amd64. 129s Preparing to unpack .../367-librust-quickcheck-dev_1.0.3-3_amd64.deb ... 129s Unpacking librust-quickcheck-dev:amd64 (1.0.3-3) ... 129s Selecting previously unselected package librust-num-bigint-dev:amd64. 129s Preparing to unpack .../368-librust-num-bigint-dev_0.4.6-1_amd64.deb ... 129s Unpacking librust-num-bigint-dev:amd64 (0.4.6-1) ... 129s Selecting previously unselected package librust-num-rational-dev:amd64. 129s Preparing to unpack .../369-librust-num-rational-dev_0.4.2-1_amd64.deb ... 129s Unpacking librust-num-rational-dev:amd64 (0.4.2-1) ... 129s Selecting previously unselected package librust-png-dev:amd64. 129s Preparing to unpack .../370-librust-png-dev_0.17.7-3_amd64.deb ... 129s Unpacking librust-png-dev:amd64 (0.17.7-3) ... 129s Selecting previously unselected package librust-qoi-dev:amd64. 129s Preparing to unpack .../371-librust-qoi-dev_0.4.1-2_amd64.deb ... 129s Unpacking librust-qoi-dev:amd64 (0.4.1-2) ... 129s Selecting previously unselected package librust-tiff-dev:amd64. 129s Preparing to unpack .../372-librust-tiff-dev_0.9.0-1_amd64.deb ... 129s Unpacking librust-tiff-dev:amd64 (0.9.0-1) ... 129s Selecting previously unselected package libsharpyuv0:amd64. 129s Preparing to unpack .../373-libsharpyuv0_1.4.0-0.1_amd64.deb ... 129s Unpacking libsharpyuv0:amd64 (1.4.0-0.1) ... 129s Selecting previously unselected package libwebp7:amd64. 129s Preparing to unpack .../374-libwebp7_1.4.0-0.1_amd64.deb ... 129s Unpacking libwebp7:amd64 (1.4.0-0.1) ... 129s Selecting previously unselected package libwebpdemux2:amd64. 129s Preparing to unpack .../375-libwebpdemux2_1.4.0-0.1_amd64.deb ... 129s Unpacking libwebpdemux2:amd64 (1.4.0-0.1) ... 129s Selecting previously unselected package libwebpmux3:amd64. 129s Preparing to unpack .../376-libwebpmux3_1.4.0-0.1_amd64.deb ... 129s Unpacking libwebpmux3:amd64 (1.4.0-0.1) ... 129s Selecting previously unselected package libwebpdecoder3:amd64. 129s Preparing to unpack .../377-libwebpdecoder3_1.4.0-0.1_amd64.deb ... 129s Unpacking libwebpdecoder3:amd64 (1.4.0-0.1) ... 129s Selecting previously unselected package libsharpyuv-dev:amd64. 129s Preparing to unpack .../378-libsharpyuv-dev_1.4.0-0.1_amd64.deb ... 129s Unpacking libsharpyuv-dev:amd64 (1.4.0-0.1) ... 129s Selecting previously unselected package libwebp-dev:amd64. 129s Preparing to unpack .../379-libwebp-dev_1.4.0-0.1_amd64.deb ... 129s Unpacking libwebp-dev:amd64 (1.4.0-0.1) ... 129s Selecting previously unselected package librust-libwebp-sys-dev:amd64. 129s Preparing to unpack .../380-librust-libwebp-sys-dev_0.9.5-1build1_amd64.deb ... 129s Unpacking librust-libwebp-sys-dev:amd64 (0.9.5-1build1) ... 129s Selecting previously unselected package librust-webp-dev:amd64. 129s Preparing to unpack .../381-librust-webp-dev_0.2.6-1_amd64.deb ... 129s Unpacking librust-webp-dev:amd64 (0.2.6-1) ... 129s Selecting previously unselected package librust-image-dev:amd64. 129s Preparing to unpack .../382-librust-image-dev_0.24.7-2_amd64.deb ... 129s Unpacking librust-image-dev:amd64 (0.24.7-2) ... 129s Selecting previously unselected package librust-plotters-backend-dev:amd64. 129s Preparing to unpack .../383-librust-plotters-backend-dev_0.3.7-1_amd64.deb ... 129s Unpacking librust-plotters-backend-dev:amd64 (0.3.7-1) ... 129s Selecting previously unselected package librust-plotters-bitmap-dev:amd64. 129s Preparing to unpack .../384-librust-plotters-bitmap-dev_0.3.3-3_amd64.deb ... 129s Unpacking librust-plotters-bitmap-dev:amd64 (0.3.3-3) ... 129s Selecting previously unselected package librust-plotters-svg-dev:amd64. 129s Preparing to unpack .../385-librust-plotters-svg-dev_0.3.5-1_amd64.deb ... 129s Unpacking librust-plotters-svg-dev:amd64 (0.3.5-1) ... 129s Selecting previously unselected package librust-web-sys-dev:amd64. 129s Preparing to unpack .../386-librust-web-sys-dev_0.3.64-2_amd64.deb ... 129s Unpacking librust-web-sys-dev:amd64 (0.3.64-2) ... 130s Selecting previously unselected package librust-plotters-dev:amd64. 130s Preparing to unpack .../387-librust-plotters-dev_0.3.5-4_amd64.deb ... 130s Unpacking librust-plotters-dev:amd64 (0.3.5-4) ... 130s Selecting previously unselected package librust-smol-dev. 130s Preparing to unpack .../388-librust-smol-dev_2.0.2-1_all.deb ... 130s Unpacking librust-smol-dev (2.0.2-1) ... 130s Selecting previously unselected package librust-tinytemplate-dev:amd64. 130s Preparing to unpack .../389-librust-tinytemplate-dev_1.2.1-1_amd64.deb ... 130s Unpacking librust-tinytemplate-dev:amd64 (1.2.1-1) ... 130s Selecting previously unselected package librust-criterion-dev. 130s Preparing to unpack .../390-librust-criterion-dev_0.5.1-6_all.deb ... 130s Unpacking librust-criterion-dev (0.5.1-6) ... 130s Selecting previously unselected package librust-phf-generator-dev:amd64. 130s Preparing to unpack .../391-librust-phf-generator-dev_0.11.2-2_amd64.deb ... 130s Unpacking librust-phf-generator-dev:amd64 (0.11.2-2) ... 130s Selecting previously unselected package librust-phf-codegen-dev:amd64. 130s Preparing to unpack .../392-librust-phf-codegen-dev_0.11.2-1_amd64.deb ... 130s Unpacking librust-phf-codegen-dev:amd64 (0.11.2-1) ... 130s Selecting previously unselected package librust-chrono-tz-build-dev:amd64. 130s Preparing to unpack .../393-librust-chrono-tz-build-dev_0.2.1-1_amd64.deb ... 130s Unpacking librust-chrono-tz-build-dev:amd64 (0.2.1-1) ... 130s Selecting previously unselected package librust-chrono-tz-dev:amd64. 130s Preparing to unpack .../394-librust-chrono-tz-dev_0.8.6-2_amd64.deb ... 130s Unpacking librust-chrono-tz-dev:amd64 (0.8.6-2) ... 130s Selecting previously unselected package librust-ctor-dev:amd64. 130s Preparing to unpack .../395-librust-ctor-dev_0.1.26-1_amd64.deb ... 130s Unpacking librust-ctor-dev:amd64 (0.1.26-1) ... 130s Selecting previously unselected package librust-powerfmt-macros-dev:amd64. 130s Preparing to unpack .../396-librust-powerfmt-macros-dev_0.1.0-1_amd64.deb ... 130s Unpacking librust-powerfmt-macros-dev:amd64 (0.1.0-1) ... 130s Selecting previously unselected package librust-powerfmt-dev:amd64. 130s Preparing to unpack .../397-librust-powerfmt-dev_0.2.0-1_amd64.deb ... 130s Unpacking librust-powerfmt-dev:amd64 (0.2.0-1) ... 130s Selecting previously unselected package librust-deranged-dev:amd64. 130s Preparing to unpack .../398-librust-deranged-dev_0.3.11-1_amd64.deb ... 130s Unpacking librust-deranged-dev:amd64 (0.3.11-1) ... 130s Selecting previously unselected package librust-eui48-dev:amd64. 130s Preparing to unpack .../399-librust-eui48-dev_1.1.0-2_amd64.deb ... 130s Unpacking librust-eui48-dev:amd64 (1.1.0-2) ... 130s Selecting previously unselected package librust-indenter-dev:amd64. 130s Preparing to unpack .../400-librust-indenter-dev_0.3.3-1_amd64.deb ... 130s Unpacking librust-indenter-dev:amd64 (0.3.3-1) ... 130s Selecting previously unselected package librust-eyre-dev:amd64. 130s Preparing to unpack .../401-librust-eyre-dev_0.6.12-1_amd64.deb ... 130s Unpacking librust-eyre-dev:amd64 (0.6.12-1) ... 130s Selecting previously unselected package librust-eyre+default-dev:amd64. 130s Preparing to unpack .../402-librust-eyre+default-dev_0.6.12-1_amd64.deb ... 130s Unpacking librust-eyre+default-dev:amd64 (0.6.12-1) ... 130s Selecting previously unselected package librust-fancy-regex-dev:amd64. 130s Preparing to unpack .../403-librust-fancy-regex-dev_0.11.0-2_amd64.deb ... 130s Unpacking librust-fancy-regex-dev:amd64 (0.11.0-2) ... 130s Selecting previously unselected package librust-fnv-dev:amd64. 130s Preparing to unpack .../404-librust-fnv-dev_1.0.7-1_amd64.deb ... 130s Unpacking librust-fnv-dev:amd64 (1.0.7-1) ... 130s Selecting previously unselected package librust-geo-types-dev:amd64. 130s Preparing to unpack .../405-librust-geo-types-dev_0.7.11-2_amd64.deb ... 130s Unpacking librust-geo-types-dev:amd64 (0.7.11-2) ... 130s Selecting previously unselected package librust-ghost-dev:amd64. 130s Preparing to unpack .../406-librust-ghost-dev_0.1.5-1_amd64.deb ... 130s Unpacking librust-ghost-dev:amd64 (0.1.5-1) ... 130s Selecting previously unselected package librust-hmac-dev:amd64. 130s Preparing to unpack .../407-librust-hmac-dev_0.12.1-1_amd64.deb ... 130s Unpacking librust-hmac-dev:amd64 (0.12.1-1) ... 130s Selecting previously unselected package librust-indoc-dev:amd64. 130s Preparing to unpack .../408-librust-indoc-dev_2.0.5-1_amd64.deb ... 130s Unpacking librust-indoc-dev:amd64 (2.0.5-1) ... 130s Selecting previously unselected package librust-inventory-dev:amd64. 130s Preparing to unpack .../409-librust-inventory-dev_0.3.2-1_amd64.deb ... 130s Unpacking librust-inventory-dev:amd64 (0.3.2-1) ... 130s Selecting previously unselected package librust-memoffset-dev:amd64. 130s Preparing to unpack .../410-librust-memoffset-dev_0.8.0-1_amd64.deb ... 130s Unpacking librust-memoffset-dev:amd64 (0.8.0-1) ... 130s Selecting previously unselected package librust-num-conv-dev:amd64. 130s Preparing to unpack .../411-librust-num-conv-dev_0.1.0-1_amd64.deb ... 130s Unpacking librust-num-conv-dev:amd64 (0.1.0-1) ... 130s Selecting previously unselected package librust-num-threads-dev:amd64. 130s Preparing to unpack .../412-librust-num-threads-dev_0.1.7-1_amd64.deb ... 130s Unpacking librust-num-threads-dev:amd64 (0.1.7-1) ... 130s Selecting previously unselected package librust-postgres-derive-dev:amd64. 130s Preparing to unpack .../413-librust-postgres-derive-dev_0.4.5-1_amd64.deb ... 130s Unpacking librust-postgres-derive-dev:amd64 (0.4.5-1) ... 130s Selecting previously unselected package librust-sha2-asm-dev:amd64. 130s Preparing to unpack .../414-librust-sha2-asm-dev_0.6.2-2_amd64.deb ... 130s Unpacking librust-sha2-asm-dev:amd64 (0.6.2-2) ... 130s Selecting previously unselected package librust-sha2-dev:amd64. 130s Preparing to unpack .../415-librust-sha2-dev_0.10.8-1_amd64.deb ... 130s Unpacking librust-sha2-dev:amd64 (0.10.8-1) ... 130s Selecting previously unselected package librust-unicode-bidi-dev:amd64. 130s Preparing to unpack .../416-librust-unicode-bidi-dev_0.3.13-1_amd64.deb ... 130s Unpacking librust-unicode-bidi-dev:amd64 (0.3.13-1) ... 130s Selecting previously unselected package librust-unicode-normalization-dev:amd64. 130s Preparing to unpack .../417-librust-unicode-normalization-dev_0.1.22-1_amd64.deb ... 130s Unpacking librust-unicode-normalization-dev:amd64 (0.1.22-1) ... 130s Selecting previously unselected package librust-stringprep-dev:amd64. 131s Preparing to unpack .../418-librust-stringprep-dev_0.1.2-1_amd64.deb ... 131s Unpacking librust-stringprep-dev:amd64 (0.1.2-1) ... 131s Selecting previously unselected package librust-postgres-protocol-dev:amd64. 131s Preparing to unpack .../419-librust-postgres-protocol-dev_0.6.6-2_amd64.deb ... 131s Unpacking librust-postgres-protocol-dev:amd64 (0.6.6-2) ... 131s Selecting previously unselected package librust-time-core-dev:amd64. 131s Preparing to unpack .../420-librust-time-core-dev_0.1.2-1_amd64.deb ... 131s Unpacking librust-time-core-dev:amd64 (0.1.2-1) ... 131s Selecting previously unselected package librust-time-macros-dev:amd64. 131s Preparing to unpack .../421-librust-time-macros-dev_0.2.16-1_amd64.deb ... 131s Unpacking librust-time-macros-dev:amd64 (0.2.16-1) ... 131s Selecting previously unselected package librust-time-dev:amd64. 131s Preparing to unpack .../422-librust-time-dev_0.3.36-2_amd64.deb ... 131s Unpacking librust-time-dev:amd64 (0.3.36-2) ... 131s Selecting previously unselected package librust-postgres-types-dev:amd64. 131s Preparing to unpack .../423-librust-postgres-types-dev_0.2.6-2_amd64.deb ... 131s Unpacking librust-postgres-types-dev:amd64 (0.2.6-2) ... 131s Selecting previously unselected package librust-rand-xorshift-dev:amd64. 131s Preparing to unpack .../424-librust-rand-xorshift-dev_0.3.0-2_amd64.deb ... 131s Unpacking librust-rand-xorshift-dev:amd64 (0.3.0-2) ... 131s Selecting previously unselected package librust-quick-error-dev:amd64. 131s Preparing to unpack .../425-librust-quick-error-dev_2.0.1-1_amd64.deb ... 131s Unpacking librust-quick-error-dev:amd64 (2.0.1-1) ... 131s Selecting previously unselected package librust-tempfile-dev:amd64. 131s Preparing to unpack .../426-librust-tempfile-dev_3.10.1-1_amd64.deb ... 131s Unpacking librust-tempfile-dev:amd64 (3.10.1-1) ... 131s Selecting previously unselected package librust-rusty-fork-dev:amd64. 131s Preparing to unpack .../427-librust-rusty-fork-dev_0.3.0-1_amd64.deb ... 131s Unpacking librust-rusty-fork-dev:amd64 (0.3.0-1) ... 131s Selecting previously unselected package librust-wait-timeout-dev:amd64. 131s Preparing to unpack .../428-librust-wait-timeout-dev_0.2.0-1_amd64.deb ... 131s Unpacking librust-wait-timeout-dev:amd64 (0.2.0-1) ... 131s Selecting previously unselected package librust-rusty-fork+wait-timeout-dev:amd64. 131s Preparing to unpack .../429-librust-rusty-fork+wait-timeout-dev_0.3.0-1_amd64.deb ... 131s Unpacking librust-rusty-fork+wait-timeout-dev:amd64 (0.3.0-1) ... 131s Selecting previously unselected package librust-unarray-dev:amd64. 131s Preparing to unpack .../430-librust-unarray-dev_0.1.4-1_amd64.deb ... 131s Unpacking librust-unarray-dev:amd64 (0.1.4-1) ... 131s Selecting previously unselected package librust-proptest-dev:amd64. 131s Preparing to unpack .../431-librust-proptest-dev_1.5.0-2_amd64.deb ... 131s Unpacking librust-proptest-dev:amd64 (1.5.0-2) ... 131s Selecting previously unselected package llvm-19-runtime. 131s Preparing to unpack .../432-llvm-19-runtime_1%3a19.1.2-1ubuntu1_amd64.deb ... 131s Unpacking llvm-19-runtime (1:19.1.2-1ubuntu1) ... 131s Selecting previously unselected package llvm-runtime:amd64. 131s Preparing to unpack .../433-llvm-runtime_1%3a19.0-60~exp1_amd64.deb ... 131s Unpacking llvm-runtime:amd64 (1:19.0-60~exp1) ... 131s Selecting previously unselected package llvm-19-linker-tools. 131s Preparing to unpack .../434-llvm-19-linker-tools_1%3a19.1.2-1ubuntu1_amd64.deb ... 131s Unpacking llvm-19-linker-tools (1:19.1.2-1ubuntu1) ... 131s Selecting previously unselected package libpfm4:amd64. 131s Preparing to unpack .../435-libpfm4_4.13.0+git83-g91970fe-1_amd64.deb ... 131s Unpacking libpfm4:amd64 (4.13.0+git83-g91970fe-1) ... 131s Selecting previously unselected package llvm-19. 131s Preparing to unpack .../436-llvm-19_1%3a19.1.2-1ubuntu1_amd64.deb ... 131s Unpacking llvm-19 (1:19.1.2-1ubuntu1) ... 131s Selecting previously unselected package llvm. 131s Preparing to unpack .../437-llvm_1%3a19.0-60~exp1_amd64.deb ... 131s Unpacking llvm (1:19.0-60~exp1) ... 131s Selecting previously unselected package binutils-mingw-w64-x86-64. 131s Preparing to unpack .../438-binutils-mingw-w64-x86-64_2.43.1-4ubuntu1+12_amd64.deb ... 131s Unpacking binutils-mingw-w64-x86-64 (2.43.1-4ubuntu1+12) ... 131s Selecting previously unselected package binutils-mingw-w64-i686. 132s Preparing to unpack .../439-binutils-mingw-w64-i686_2.43.1-4ubuntu1+12_amd64.deb ... 132s Unpacking binutils-mingw-w64-i686 (2.43.1-4ubuntu1+12) ... 132s Selecting previously unselected package librust-python3-dll-a-dev:amd64. 132s Preparing to unpack .../440-librust-python3-dll-a-dev_0.2.10-1_amd64.deb ... 132s Unpacking librust-python3-dll-a-dev:amd64 (0.2.10-1) ... 132s Selecting previously unselected package librust-target-lexicon-dev:amd64. 132s Preparing to unpack .../441-librust-target-lexicon-dev_0.12.14-1_amd64.deb ... 132s Unpacking librust-target-lexicon-dev:amd64 (0.12.14-1) ... 132s Selecting previously unselected package librust-pyo3-build-config-dev:amd64. 132s Preparing to unpack .../442-librust-pyo3-build-config-dev_0.22.6-1_amd64.deb ... 132s Unpacking librust-pyo3-build-config-dev:amd64 (0.22.6-1) ... 132s Selecting previously unselected package python3.12-dev. 132s Preparing to unpack .../443-python3.12-dev_3.12.7-3_amd64.deb ... 132s Unpacking python3.12-dev (3.12.7-3) ... 132s Selecting previously unselected package librust-pyo3-ffi-dev:amd64. 132s Preparing to unpack .../444-librust-pyo3-ffi-dev_0.22.6-1build1_amd64.deb ... 132s Unpacking librust-pyo3-ffi-dev:amd64 (0.22.6-1build1) ... 132s Selecting previously unselected package librust-pyo3-macros-backend-dev:amd64. 132s Preparing to unpack .../445-librust-pyo3-macros-backend-dev_0.22.6-1_amd64.deb ... 132s Unpacking librust-pyo3-macros-backend-dev:amd64 (0.22.6-1) ... 132s Selecting previously unselected package librust-pyo3-macros-dev:amd64. 132s Preparing to unpack .../446-librust-pyo3-macros-dev_0.22.6-1_amd64.deb ... 132s Unpacking librust-pyo3-macros-dev:amd64 (0.22.6-1) ... 132s Selecting previously unselected package librust-rust-decimal-dev:amd64. 132s Preparing to unpack .../447-librust-rust-decimal-dev_1.36.0-1_amd64.deb ... 132s Unpacking librust-rust-decimal-dev:amd64 (1.36.0-1) ... 132s Selecting previously unselected package librust-unindent-dev:amd64. 132s Preparing to unpack .../448-librust-unindent-dev_0.2.3-1_amd64.deb ... 132s Unpacking librust-unindent-dev:amd64 (0.2.3-1) ... 132s Selecting previously unselected package librust-pyo3-dev:amd64. 132s Preparing to unpack .../449-librust-pyo3-dev_0.22.6-1_amd64.deb ... 132s Unpacking librust-pyo3-dev:amd64 (0.22.6-1) ... 132s Selecting previously unselected package librust-rustc-hash-dev:amd64. 132s Preparing to unpack .../450-librust-rustc-hash-dev_1.1.0-1_amd64.deb ... 132s Unpacking librust-rustc-hash-dev:amd64 (1.1.0-1) ... 132s Selecting previously unselected package pybuild-plugin-autopkgtest. 132s Preparing to unpack .../451-pybuild-plugin-autopkgtest_6.20241024_all.deb ... 132s Unpacking pybuild-plugin-autopkgtest (6.20241024) ... 132s Selecting previously unselected package python3-packaging. 132s Preparing to unpack .../452-python3-packaging_24.2-1_all.deb ... 132s Unpacking python3-packaging (24.2-1) ... 132s Selecting previously unselected package python3-pyproject-hooks. 132s Preparing to unpack .../453-python3-pyproject-hooks_1.2.0-1_all.deb ... 132s Unpacking python3-pyproject-hooks (1.2.0-1) ... 132s Selecting previously unselected package python3-toml. 132s Preparing to unpack .../454-python3-toml_0.10.2-1_all.deb ... 132s Unpacking python3-toml (0.10.2-1) ... 132s Selecting previously unselected package python3-wheel. 132s Preparing to unpack .../455-python3-wheel_0.45.0-1_all.deb ... 132s Unpacking python3-wheel (0.45.0-1) ... 132s Selecting previously unselected package python3-build. 132s Preparing to unpack .../456-python3-build_1.2.2-1_all.deb ... 132s Unpacking python3-build (1.2.2-1) ... 132s Selecting previously unselected package python3-installer. 132s Preparing to unpack .../457-python3-installer_0.7.0+dfsg1-3_all.deb ... 132s Unpacking python3-installer (0.7.0+dfsg1-3) ... 132s Selecting previously unselected package pybuild-plugin-pyproject. 132s Preparing to unpack .../458-pybuild-plugin-pyproject_6.20241024_all.deb ... 132s Unpacking pybuild-plugin-pyproject (6.20241024) ... 132s Selecting previously unselected package python3.13. 132s Preparing to unpack .../459-python3.13_3.13.0-2_amd64.deb ... 132s Unpacking python3.13 (3.13.0-2) ... 132s Selecting previously unselected package python3-all. 132s Preparing to unpack .../460-python3-all_3.12.7-1_amd64.deb ... 132s Unpacking python3-all (3.12.7-1) ... 132s Selecting previously unselected package python3-dateutil. 132s Preparing to unpack .../461-python3-dateutil_2.9.0-3_all.deb ... 132s Unpacking python3-dateutil (2.9.0-3) ... 132s Selecting previously unselected package python3-sortedcontainers. 132s Preparing to unpack .../462-python3-sortedcontainers_2.4.0-2_all.deb ... 132s Unpacking python3-sortedcontainers (2.4.0-2) ... 132s Selecting previously unselected package python3-hypothesis. 132s Preparing to unpack .../463-python3-hypothesis_6.119.3-1_all.deb ... 132s Unpacking python3-hypothesis (6.119.3-1) ... 133s Selecting previously unselected package python3-iniconfig. 133s Preparing to unpack .../464-python3-iniconfig_1.1.1-2_all.deb ... 133s Unpacking python3-iniconfig (1.1.1-2) ... 133s Selecting previously unselected package python3-pluggy. 133s Preparing to unpack .../465-python3-pluggy_1.5.0-1_all.deb ... 133s Unpacking python3-pluggy (1.5.0-1) ... 133s Selecting previously unselected package python3-pytest. 133s Preparing to unpack .../466-python3-pytest_8.3.3-1_all.deb ... 133s Unpacking python3-pytest (8.3.3-1) ... 133s Selecting previously unselected package python3-regex. 133s Preparing to unpack .../467-python3-regex_0.1.20240724-1build1_amd64.deb ... 133s Unpacking python3-regex (0.1.20240724-1build1) ... 133s Selecting previously unselected package python3-semantic-version. 133s Preparing to unpack .../468-python3-semantic-version_2.10.0-2_all.deb ... 133s Unpacking python3-semantic-version (2.10.0-2) ... 133s Selecting previously unselected package rustc. 133s Preparing to unpack .../469-rustc_1.80.1ubuntu2_amd64.deb ... 133s Unpacking rustc (1.80.1ubuntu2) ... 133s Selecting previously unselected package cargo. 133s Preparing to unpack .../470-cargo_1.80.1ubuntu2_amd64.deb ... 133s Unpacking cargo (1.80.1ubuntu2) ... 133s Selecting previously unselected package python3-setuptools-rust. 133s Preparing to unpack .../471-python3-setuptools-rust_1.9.0+dfsg-2_all.deb ... 133s Unpacking python3-setuptools-rust (1.9.0+dfsg-2) ... 133s Selecting previously unselected package python3-tiktoken. 133s Preparing to unpack .../472-python3-tiktoken_0.8.0-1build1_amd64.deb ... 133s Unpacking python3-tiktoken (0.8.0-1build1) ... 133s Selecting previously unselected package autopkgtest-satdep. 133s Preparing to unpack .../473-1-autopkgtest-satdep.deb ... 133s Unpacking autopkgtest-satdep (0) ... 133s Setting up dh-python (6.20241024) ... 133s Setting up librust-ciborium-io-dev:amd64 (0.2.2-1) ... 133s Setting up librust-crossbeam-utils-dev:amd64 (0.8.19-1) ... 133s Setting up librust-parking-dev:amd64 (2.2.0-1) ... 133s Setting up librust-ppv-lite86-dev:amd64 (0.2.16-1) ... 133s Setting up python3-iniconfig (1.1.1-2) ... 133s Setting up libsharpyuv0:amd64 (1.4.0-0.1) ... 133s Setting up librust-pin-utils-dev:amd64 (0.1.0-1) ... 133s Setting up librust-fnv-dev:amd64 (1.0.7-1) ... 133s Setting up librust-libc-dev:amd64 (0.2.155-1) ... 133s Setting up librust-unindent-dev:amd64 (0.2.3-1) ... 133s Setting up librust-quick-error-dev:amd64 (2.0.1-1) ... 133s Setting up librust-is-terminal-dev:amd64 (0.4.13-1) ... 133s Setting up librust-traitobject-dev:amd64 (0.1.0-1) ... 133s Setting up librust-either-dev:amd64 (1.13.0-1) ... 133s Setting up binutils-mingw-w64-x86-64 (2.43.1-4ubuntu1+12) ... 133s Setting up librust-adler-dev:amd64 (1.0.2-2) ... 133s Setting up librust-version-check-dev:amd64 (0.9.5-1) ... 133s Setting up librust-base64-dev:amd64 (0.21.7-1) ... 133s Setting up librust-indoc-dev:amd64 (2.0.5-1) ... 133s Setting up librust-anstyle-dev:amd64 (1.0.8-1) ... 133s Setting up librust-winapi-i686-pc-windows-gnu-dev:amd64 (0.4.0-1) ... 133s Setting up librust-futures-task-dev:amd64 (0.3.30-1) ... 133s Setting up librust-rustc-hash-dev:amd64 (1.1.0-1) ... 133s Setting up librust-wasm-bindgen-shared-dev:amd64 (0.2.87-1) ... 133s Setting up libarchive-zip-perl (1.68-1) ... 133s Setting up librust-colorchoice-dev:amd64 (1.0.0-1) ... 133s Setting up librust-fastrand-dev:amd64 (2.1.1-1) ... 133s Setting up librust-socket2-dev:amd64 (0.5.7-1) ... 133s Setting up libdebhelper-perl (13.20ubuntu1) ... 133s Setting up librust-unsafe-any-dev:amd64 (0.4.2-2) ... 133s Setting up librust-tinyvec-macros-dev:amd64 (0.1.0-1) ... 133s Setting up librust-num-cpus-dev:amd64 (1.16.0-1) ... 133s Setting up librust-libm-dev:amd64 (0.2.8-1) ... 133s Setting up librust-strsim-dev:amd64 (0.11.1-1) ... 133s Setting up libwebpdecoder3:amd64 (1.4.0-0.1) ... 133s Setting up m4 (1.4.19-4build1) ... 133s Setting up librust-rustc-demangle-dev:amd64 (0.1.21-1) ... 133s Setting up librust-cpufeatures-dev:amd64 (0.2.11-1) ... 133s Setting up librust-const-cstr-dev:amd64 (0.3.0-1) ... 133s Setting up librust-fallible-iterator-dev:amd64 (0.3.0-2) ... 133s Setting up librust-ryu-dev:amd64 (1.0.15-1) ... 133s Setting up python3-sortedcontainers (2.4.0-2) ... 133s Setting up librust-humantime-dev:amd64 (2.1.0-1) ... 133s Setting up librust-anstyle-query-dev:amd64 (1.0.0-1) ... 133s Setting up librust-cast-dev:amd64 (0.3.0-1) ... 133s Setting up libgomp1:amd64 (14.2.0-8ubuntu1) ... 133s Setting up librust-subtle-dev:amd64 (2.6.1-1) ... 133s Setting up librust-simdutf8-dev:amd64 (0.1.4-4) ... 133s Setting up librust-atomic-waker-dev:amd64 (1.1.2-1) ... 133s Setting up librust-miniz-oxide-dev:amd64 (0.7.1-1) ... 133s Setting up librust-pin-project-lite-dev:amd64 (0.2.13-1) ... 133s Setting up python3-wheel (0.45.0-1) ... 134s Setting up librust-unicode-segmentation-dev:amd64 (1.11.0-1) ... 134s Setting up librust-typemap-dev:amd64 (0.3.3-2) ... 134s Setting up libpython3.13-minimal:amd64 (3.13.0-2) ... 134s Setting up librust-compiler-builtins-dev:amd64 (0.1.101-1) ... 134s Setting up librust-weezl-dev:amd64 (0.1.5-1) ... 134s Setting up librust-utf8parse-dev:amd64 (0.2.1-1) ... 134s Setting up librust-signal-hook-registry-dev:amd64 (1.4.0-1) ... 134s Setting up librust-crossbeam-epoch-dev:amd64 (0.9.18-1) ... 134s Setting up autotools-dev (20220109.1) ... 134s Setting up librust-tap-dev:amd64 (1.0.1-1) ... 134s Setting up librust-errno-dev:amd64 (0.3.8-1) ... 134s Setting up python3-packaging (24.2-1) ... 134s Setting up librust-array-init-dev:amd64 (2.0.1-1) ... 134s Setting up libpkgconf3:amd64 (1.8.1-4) ... 134s Setting up libpfm4:amd64 (4.13.0+git83-g91970fe-1) ... 134s Setting up librust-oorandom-dev:amd64 (11.1.3-1) ... 134s Setting up libexpat1-dev:amd64 (2.6.4-1) ... 134s Setting up python3-pyproject-hooks (1.2.0-1) ... 134s Setting up librust-rustc-std-workspace-core-dev:amd64 (1.0.0-1) ... 134s Setting up librust-funty-dev:amd64 (2.0.0-1) ... 134s Setting up librust-futures-io-dev:amd64 (0.3.31-1) ... 134s Setting up librust-typenum-dev:amd64 (1.17.0-2) ... 134s Setting up uuid-dev:amd64 (2.40.2-1ubuntu1) ... 134s Setting up librust-core-maths-dev:amd64 (0.1.0-2) ... 134s Setting up librust-stable-deref-trait-dev:amd64 (1.2.0-1) ... 134s Setting up librust-critical-section-dev:amd64 (1.1.3-1) ... 134s Setting up libquadmath0:amd64 (14.2.0-8ubuntu1) ... 134s Setting up librust-scopeguard-dev:amd64 (1.2.0-1) ... 134s Setting up librust-iana-time-zone-dev:amd64 (0.1.60-1) ... 134s Setting up fonts-dejavu-mono (2.37-8) ... 134s Setting up libmpc3:amd64 (1.3.1-1build2) ... 134s Setting up librust-rand-core-dev:amd64 (0.6.4-2) ... 134s Setting up python3-semantic-version (2.10.0-2) ... 134s Setting up librust-jobserver-dev:amd64 (0.1.32-1) ... 134s Setting up autopoint (0.22.5-2) ... 134s Setting up libjsoncpp25:amd64 (1.9.5-6build1) ... 134s Setting up fonts-dejavu-core (2.37-8) ... 134s Setting up librust-seahash-dev:amd64 (4.1.0-1) ... 134s Setting up pkgconf-bin (1.8.1-4) ... 134s Setting up librust-ab-glyph-rasterizer-dev:amd64 (0.1.7-1) ... 134s Setting up binutils-mingw-w64-i686 (2.43.1-4ubuntu1+12) ... 134s Setting up librust-time-core-dev:amd64 (0.1.2-1) ... 134s Setting up python3-regex (0.1.20240724-1build1) ... 135s Setting up librust-crunchy-dev:amd64 (0.2.2-1) ... 135s Setting up python3-toml (0.10.2-1) ... 135s Setting up librust-unicase-dev:amd64 (2.7.0-1) ... 135s Setting up librust-unicode-width-dev:amd64 (0.1.14-1) ... 135s Setting up python3-installer (0.7.0+dfsg1-3) ... 135s Setting up autoconf (2.72-3) ... 135s Setting up python3-pluggy (1.5.0-1) ... 135s Setting up libwebp7:amd64 (1.4.0-0.1) ... 135s Setting up libubsan1:amd64 (14.2.0-8ubuntu1) ... 135s Setting up zlib1g-dev:amd64 (1:1.3.dfsg+really1.3.1-1ubuntu1) ... 135s Setting up librust-unicode-ident-dev:amd64 (1.0.13-1) ... 135s Setting up librust-equivalent-dev:amd64 (1.0.1-1) ... 135s Setting up dwz (0.15-1build6) ... 135s Setting up librust-bitflags-1-dev:amd64 (1.3.2-5) ... 135s Setting up librust-uncased-dev:amd64 (0.9.6-2) ... 135s Setting up librust-slog-dev:amd64 (2.7.0-1) ... 135s Setting up python3-tiktoken (0.8.0-1build1) ... 135s Setting up librust-pure-rust-locales-dev:amd64 (0.8.1-1) ... 135s Setting up libhwasan0:amd64 (14.2.0-8ubuntu1) ... 135s Setting up librhash0:amd64 (1.4.3-3build1) ... 135s Setting up libasan8:amd64 (14.2.0-8ubuntu1) ... 135s Setting up librust-wait-timeout-dev:amd64 (0.2.0-1) ... 135s Setting up librust-ttf-parser-dev:amd64 (0.24.1-1) ... 135s Setting up librust-cfg-if-dev:amd64 (1.0.0-1) ... 135s Setting up debugedit (1:5.1-1) ... 135s Setting up librust-color-quant-dev:amd64 (1.1.0-1) ... 135s Setting up python3.13-minimal (3.13.0-2) ... 136s Setting up python3-dateutil (2.9.0-3) ... 136s Setting up librust-blobby-dev:amd64 (0.3.1-1) ... 136s Setting up cmake-data (3.30.3-1) ... 136s Setting up llvm-19-linker-tools (1:19.1.2-1ubuntu1) ... 136s Setting up librust-byteorder-dev:amd64 (1.5.0-1) ... 136s Setting up libtsan2:amd64 (14.2.0-8ubuntu1) ... 136s Setting up librust-static-assertions-dev:amd64 (1.1.0-1) ... 136s Setting up librust-compiler-builtins+core-dev:amd64 (0.1.101-1) ... 136s Setting up librust-float-ord-dev:amd64 (0.3.2-1) ... 136s Setting up librust-autocfg-dev:amd64 (1.1.0-1) ... 136s Setting up libisl23:amd64 (0.27-1) ... 136s Setting up librust-time-macros-dev:amd64 (0.2.16-1) ... 136s Setting up llvm-19-runtime (1:19.1.2-1ubuntu1) ... 136s Setting up librust-futures-sink-dev:amd64 (0.3.31-1) ... 136s Setting up python3-build (1.2.2-1) ... 136s Setting up libsharpyuv-dev:amd64 (1.4.0-0.1) ... 136s Setting up librust-cfg-if-0.1-dev:amd64 (0.1.10-2) ... 136s Setting up librust-tinyvec-dev:amd64 (1.6.0-2) ... 136s Setting up libwebpmux3:amd64 (1.4.0-0.1) ... 136s Setting up librust-plotters-backend-dev:amd64 (0.3.7-1) ... 136s Setting up librust-shlex-dev:amd64 (1.3.0-1) ... 136s Setting up libpython3.13-stdlib:amd64 (3.13.0-2) ... 136s Setting up librust-indenter-dev:amd64 (0.3.3-1) ... 136s Setting up librust-cpp-demangle-dev:amd64 (0.4.0-1) ... 136s Setting up librust-winapi-x86-64-pc-windows-gnu-dev:amd64 (0.4.0-1) ... 136s Setting up libcc1-0:amd64 (14.2.0-8ubuntu1) ... 136s Setting up libbrotli-dev:amd64 (1.1.0-2build3) ... 136s Setting up liblsan0:amd64 (14.2.0-8ubuntu1) ... 136s Setting up libitm1:amd64 (14.2.0-8ubuntu1) ... 136s Setting up librust-clap-lex-dev:amd64 (0.7.2-2) ... 136s Setting up libhttp-parser2.9:amd64 (2.9.4-6build1) ... 136s Setting up librust-unarray-dev:amd64 (0.1.4-1) ... 136s Setting up libstd-rust-1.80:amd64 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 136s Setting up librust-itertools-dev:amd64 (0.10.5-1) ... 136s Setting up librust-heck-dev:amd64 (0.4.1-1) ... 136s Setting up libbz2-dev:amd64 (1.0.8-6) ... 136s Setting up librust-num-conv-dev:amd64 (0.1.0-1) ... 136s Setting up libpython3.13:amd64 (3.13.0-2) ... 136s Setting up automake (1:1.16.5-1.3ubuntu1) ... 136s update-alternatives: using /usr/bin/automake-1.16 to provide /usr/bin/automake (automake) in auto mode 136s Setting up libfile-stripnondeterminism-perl (1.14.0-1) ... 136s Setting up librust-owned-ttf-parser-dev:amd64 (0.24.0-1) ... 136s Setting up librust-num-threads-dev:amd64 (0.1.7-1) ... 136s Setting up librust-crossbeam-epoch+std-dev:amd64 (0.9.18-1) ... 136s Setting up gettext (0.22.5-2) ... 136s Setting up librust-gif-dev:amd64 (0.11.3-1) ... 136s Setting up librust-crossbeam-deque-dev:amd64 (0.8.5-1) ... 136s Setting up librust-tiny-keccak-dev:amd64 (2.0.2-1) ... 136s Setting up python3.13 (3.13.0-2) ... 137s Setting up librust-linux-raw-sys-dev:amd64 (0.4.14-1) ... 137s Setting up pybuild-plugin-pyproject (6.20241024) ... 137s Setting up fontconfig-config (2.15.0-1.1ubuntu2) ... 137s Setting up librust-getrandom-dev:amd64 (0.2.12-1) ... 137s Setting up python3-pytest (8.3.3-1) ... 138s Setting up librust-libloading-dev:amd64 (0.8.5-1) ... 138s Setting up librust-memmap2-dev:amd64 (0.9.3-1) ... 138s Setting up libwebpdemux2:amd64 (1.4.0-0.1) ... 138s Setting up python3-hypothesis (6.119.3-1) ... 139s Setting up librust-ab-glyph-rasterizer+libm-dev:amd64 (0.1.7-1) ... 139s Setting up libpng-dev:amd64 (1.6.44-2) ... 139s Setting up librust-tinyvec+tinyvec-macros-dev:amd64 (1.6.0-2) ... 139s Setting up librust-owning-ref-dev:amd64 (0.4.1-1) ... 139s Setting up librust-memoffset-dev:amd64 (0.8.0-1) ... 139s Setting up python3-all (3.12.7-1) ... 139s Setting up libpython3.12-dev:amd64 (3.12.7-3) ... 139s Setting up librust-proc-macro2-dev:amd64 (1.0.86-1) ... 139s Setting up librust-compiler-builtins+rustc-dep-of-std-dev:amd64 (0.1.101-1) ... 139s Setting up librust-rayon-core-dev:amd64 (1.12.1-1) ... 139s Setting up librust-winapi-dev:amd64 (0.3.9-1) ... 139s Setting up pkgconf:amd64 (1.8.1-4) ... 139s Setting up librust-ab-glyph-dev:amd64 (0.2.28-1) ... 139s Setting up libstd-rust-1.80-dev:amd64 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 139s Setting up libfreetype-dev:amd64 (2.13.3+dfsg-1) ... 139s Setting up intltool-debian (0.35.0+20060710.6) ... 139s Setting up librust-rand-core+getrandom-dev:amd64 (0.6.4-2) ... 139s Setting up librust-rand-xorshift-dev:amd64 (0.3.0-2) ... 139s Setting up libwebp-dev:amd64 (1.4.0-0.1) ... 139s Setting up librust-anes-dev:amd64 (0.1.6-1) ... 139s Setting up libpython3.13-dev:amd64 (3.13.0-2) ... 139s Setting up llvm-runtime:amd64 (1:19.0-60~exp1) ... 139s Setting up librust-cc-dev:amd64 (1.1.14-1) ... 139s Setting up python3.12-dev (3.12.7-3) ... 139s Setting up pkg-config:amd64 (1.8.1-4) ... 139s Setting up cpp-14-x86-64-linux-gnu (14.2.0-8ubuntu1) ... 139s Setting up cpp-14 (14.2.0-8ubuntu1) ... 139s Setting up dh-strip-nondeterminism (1.14.0-1) ... 139s Setting up librust-crc32fast-dev:amd64 (1.4.2-1) ... 139s Setting up librust-num-traits-dev:amd64 (0.2.19-2) ... 139s Setting up librust-winapi-util-dev:amd64 (0.1.6-1) ... 139s Setting up cmake (3.30.3-1) ... 139s Setting up libgit2-1.7:amd64 (1.7.2+ds-1ubuntu3) ... 139s Setting up llvm-19 (1:19.1.2-1ubuntu1) ... 139s Setting up libfontconfig1:amd64 (2.15.0-1.1ubuntu2) ... 139s Setting up librust-sha1-asm-dev:amd64 (0.5.1-2) ... 139s Setting up libgcc-14-dev:amd64 (14.2.0-8ubuntu1) ... 139s Setting up librust-same-file-dev:amd64 (1.0.6-1) ... 139s Setting up librust-rayon-dev:amd64 (1.10.0-1) ... 139s Setting up librust-termcolor-dev:amd64 (1.4.1-1) ... 139s Setting up librust-pkg-config-dev:amd64 (0.3.27-1) ... 139s Setting up libstdc++-14-dev:amd64 (14.2.0-8ubuntu1) ... 139s Setting up librust-jpeg-decoder-dev:amd64 (0.3.0-1) ... 139s Setting up librust-dirs-sys-next-dev:amd64 (0.1.1-1) ... 139s Setting up cpp-x86-64-linux-gnu (4:14.1.0-2ubuntu1) ... 139s Setting up librust-cmake-dev:amd64 (0.1.45-1) ... 139s Setting up librust-num-integer-dev:amd64 (0.1.46-1) ... 139s Setting up librust-dirs-next-dev:amd64 (2.0.0-1) ... 139s Setting up libpython3-dev:amd64 (3.12.7-1) ... 139s Setting up librust-dlib-dev:amd64 (0.5.2-2) ... 139s Setting up libfontconfig-dev:amd64 (2.15.0-1.1ubuntu2) ... 139s Setting up librust-sha2-asm-dev:amd64 (0.6.2-2) ... 139s Setting up librust-libwebp-sys-dev:amd64 (0.9.5-1build1) ... 139s Setting up po-debconf (1.0.21+nmu1) ... 139s Setting up librust-quote-dev:amd64 (1.0.37-1) ... 139s Setting up librust-freetype-sys-dev:amd64 (0.13.1-1) ... 139s Setting up librust-libz-sys-dev:amd64 (1.1.20-1) ... 139s Setting up librust-syn-dev:amd64 (2.0.85-1) ... 139s Setting up librust-rand-core+std-dev:amd64 (0.6.4-2) ... 139s Setting up librust-powerfmt-macros-dev:amd64 (0.1.0-1) ... 139s Setting up librust-powerfmt-dev:amd64 (0.2.0-1) ... 139s Setting up librust-sval-derive-dev:amd64 (2.6.1-2) ... 139s Setting up libpython3-all-dev:amd64 (3.12.7-1) ... 139s Setting up librust-md5-asm-dev:amd64 (0.5.0-2) ... 139s Setting up librust-freetype-dev:amd64 (0.7.0-4) ... 139s Setting up librust-zeroize-derive-dev:amd64 (1.4.2-1) ... 139s Setting up llvm (1:19.0-60~exp1) ... 139s Setting up librust-postgres-derive-dev:amd64 (0.4.5-1) ... 139s Setting up librust-syn-1-dev:amd64 (1.0.109-2) ... 139s Setting up librust-clap-derive-dev:amd64 (4.5.13-2) ... 139s Setting up librust-bytecheck-derive-dev:amd64 (0.6.12-1) ... 139s Setting up librust-no-panic-dev:amd64 (0.1.13-1) ... 139s Setting up cpp (4:14.1.0-2ubuntu1) ... 139s Setting up librust-serde-derive-dev:amd64 (1.0.210-1) ... 139s Setting up librust-walkdir-dev:amd64 (2.5.0-1) ... 139s Setting up librust-zerocopy-derive-dev:amd64 (0.7.32-2) ... 139s Setting up gcc-14-x86-64-linux-gnu (14.2.0-8ubuntu1) ... 139s Setting up librust-valuable-derive-dev:amd64 (0.1.0-1) ... 139s Setting up librust-ghost-dev:amd64 (0.1.5-1) ... 139s Setting up librust-serde-dev:amd64 (1.0.210-2) ... 139s Setting up librust-bytemuck-derive-dev:amd64 (1.5.0-2) ... 139s Setting up librust-derive-arbitrary-dev:amd64 (1.3.2-1) ... 139s Setting up librust-allocator-api2-dev:amd64 (0.2.16-1) ... 139s Setting up librust-async-attributes-dev (1.1.2-6) ... 139s Setting up librust-rand-chacha-dev:amd64 (0.3.1-2) ... 139s Setting up librust-futures-macro-dev:amd64 (0.3.30-1) ... 139s Setting up librust-ctor-dev:amd64 (0.1.26-1) ... 139s Setting up librust-unicode-bidi-dev:amd64 (0.3.13-1) ... 139s Setting up librust-tracing-attributes-dev:amd64 (0.1.27-1) ... 139s Setting up librust-ptr-meta-derive-dev:amd64 (0.1.4-1) ... 139s Setting up gcc-x86-64-linux-gnu (4:14.1.0-2ubuntu1) ... 139s Setting up librust-serde-fmt-dev (1.0.3-3) ... 139s Setting up librust-portable-atomic-dev:amd64 (1.9.0-4) ... 139s Setting up librust-tokio-macros-dev:amd64 (2.4.0-2) ... 139s Setting up librust-flate2-dev:amd64 (1.0.34-1) ... 139s Setting up librust-lock-api-dev:amd64 (0.4.12-1) ... 139s Setting up librust-ptr-meta-dev:amd64 (0.1.4-1) ... 139s Setting up librust-inventory-dev:amd64 (0.3.2-1) ... 139s Setting up librust-sval-dev:amd64 (2.6.1-2) ... 139s Setting up librust-itoa-dev:amd64 (1.0.9-1) ... 139s Setting up gcc-14 (14.2.0-8ubuntu1) ... 139s Setting up librust-bytes-dev:amd64 (1.8.0-1) ... 139s Setting up librust-bumpalo-dev:amd64 (3.16.0-1) ... 139s Setting up librust-python3-dll-a-dev:amd64 (0.2.10-1) ... 139s Setting up librust-siphasher-dev:amd64 (0.3.10-1) ... 139s Setting up librust-rand-core+serde-dev:amd64 (0.6.4-2) ... 139s Setting up librust-sval-ref-dev:amd64 (2.6.1-1) ... 139s Setting up librust-rkyv-derive-dev:amd64 (0.7.44-1) ... 139s Setting up librust-zerocopy-dev:amd64 (0.7.32-1) ... 139s Setting up librust-semver-dev:amd64 (1.0.23-1) ... 139s Setting up librust-bytemuck-dev:amd64 (1.14.0-1) ... 139s Setting up librust-bit-vec-dev:amd64 (0.6.3-1) ... 139s Setting up librust-zeroize-dev:amd64 (1.8.1-1) ... 139s Setting up g++-14-x86-64-linux-gnu (14.2.0-8ubuntu1) ... 139s Setting up librust-slab-dev:amd64 (0.4.9-1) ... 139s Setting up librust-arbitrary-dev:amd64 (1.3.2-1) ... 139s Setting up librust-valuable-dev:amd64 (0.1.0-4) ... 139s Setting up librust-target-lexicon-dev:amd64 (0.12.14-1) ... 139s Setting up librust-serde-test-dev:amd64 (1.0.171-1) ... 139s Setting up librust-bit-set-dev:amd64 (0.5.2-1) ... 139s Setting up g++-x86-64-linux-gnu (4:14.1.0-2ubuntu1) ... 139s Setting up librust-concurrent-queue-dev:amd64 (2.5.0-4) ... 139s Setting up g++-14 (14.2.0-8ubuntu1) ... 139s Setting up librust-erased-serde-dev:amd64 (0.3.31-1) ... 139s Setting up librust-radium-dev:amd64 (1.1.0-1) ... 139s Setting up librust-bit-set+std-dev:amd64 (0.5.2-1) ... 139s Setting up librust-phf-shared-dev:amd64 (0.11.2-1) ... 139s Setting up librust-tiff-dev:amd64 (0.9.0-1) ... 139s Setting up librust-smol-str-dev:amd64 (0.2.0-1) ... 139s Setting up librust-atomic-dev:amd64 (0.6.0-1) ... 139s Setting up librust-generic-array-dev:amd64 (0.14.7-1) ... 139s Setting up librust-half-dev:amd64 (1.8.2-4) ... 139s Setting up librust-phf-dev:amd64 (0.11.2-1) ... 139s Setting up librust-spin-dev:amd64 (0.9.8-4) ... 139s Setting up librust-sval-dynamic-dev:amd64 (2.6.1-1) ... 139s Setting up librust-qoi-dev:amd64 (0.4.1-2) ... 139s Setting up librust-async-task-dev (4.7.1-3) ... 139s Setting up librust-crypto-common-dev:amd64 (0.1.6-1) ... 139s Setting up librust-ciborium-ll-dev:amd64 (0.2.2-1) ... 139s Setting up librust-futures-core-dev:amd64 (0.3.30-1) ... 139s Setting up librust-lazy-static-dev:amd64 (1.5.0-1) ... 139s Setting up libtool (2.4.7-8) ... 139s Setting up librust-sval-buffer-dev:amd64 (2.6.1-1) ... 139s Setting up librust-arrayvec-dev:amd64 (0.7.4-2) ... 139s Setting up librust-png-dev:amd64 (0.17.7-3) ... 139s Setting up librust-rustc-version-dev:amd64 (0.4.0-1) ... 139s Setting up librust-event-listener-dev (5.3.1-8) ... 139s Setting up librust-smallvec-dev:amd64 (1.13.2-1) ... 139s Setting up librust-sval-fmt-dev:amd64 (2.6.1-1) ... 139s Setting up librust-const-oid-dev:amd64 (0.9.3-1) ... 139s Setting up gcc (4:14.1.0-2ubuntu1) ... 139s Setting up librust-anstyle-parse-dev:amd64 (0.2.1-1) ... 139s Setting up rustc-1.80 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 139s Setting up dh-autoreconf (20) ... 139s Setting up librust-ciborium-dev:amd64 (0.2.2-2) ... 139s Setting up librust-block-buffer-dev:amd64 (0.10.2-2) ... 139s Setting up librust-pathfinder-simd-dev:amd64 (0.5.2-1) ... 139s Setting up librust-unicode-normalization-dev:amd64 (0.1.22-1) ... 139s Setting up librust-anstream-dev:amd64 (0.6.15-1) ... 139s Setting up librust-bitflags-dev:amd64 (2.6.0-1) ... 139s Setting up librust-regex-syntax-dev:amd64 (0.8.2-1) ... 139s Setting up g++ (4:14.1.0-2ubuntu1) ... 139s update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode 139s Setting up rustc (1.80.1ubuntu2) ... 139s Setting up librust-parking-lot-core-dev:amd64 (0.9.10-1) ... 139s Setting up build-essential (12.10ubuntu1) ... 139s Setting up librust-futures-channel-dev:amd64 (0.3.30-1) ... 139s Setting up cargo-1.80 (1.80.1+dfsg0ubuntu1-0ubuntu1) ... 139s Setting up librust-once-cell-dev:amd64 (1.20.2-1) ... 139s Setting up librust-pyo3-build-config-dev:amd64 (0.22.6-1) ... 139s Setting up librust-phf-shared+uncased-dev:amd64 (0.11.2-1) ... 139s Setting up librust-digest-dev:amd64 (0.10.7-2) ... 139s Setting up librust-md-5-dev:amd64 (0.10.6-1) ... 139s Setting up librust-sval-serde-dev:amd64 (2.6.1-1) ... 139s Setting up librust-parking-lot-dev:amd64 (0.12.3-1) ... 139s Setting up librust-event-listener-strategy-dev:amd64 (0.5.2-3) ... 139s Setting up librust-pyo3-macros-backend-dev:amd64 (0.22.6-1) ... 139s Setting up librust-pyo3-ffi-dev:amd64 (0.22.6-1build1) ... 139s Setting up librust-const-random-macro-dev:amd64 (0.1.16-2) ... 139s Setting up librust-const-random-dev:amd64 (0.1.17-2) ... 139s Setting up librust-pyo3-macros-dev:amd64 (0.22.6-1) ... 139s Setting up librust-sha1-dev:amd64 (0.10.6-1) ... 139s Setting up debhelper (13.20ubuntu1) ... 139s Setting up librust-ahash-dev (0.8.11-8) ... 139s Setting up librust-async-channel-dev (2.3.1-8) ... 139s Setting up librust-stringprep-dev:amd64 (0.1.2-1) ... 139s Setting up librust-tracing-core-dev:amd64 (0.1.32-1) ... 139s Setting up cargo (1.80.1ubuntu2) ... 139s Setting up librust-async-lock-dev (3.4.0-4) ... 139s Setting up python3-setuptools-rust (1.9.0+dfsg-2) ... 139s Setting up librust-eyre-dev:amd64 (0.6.12-1) ... 139s Setting up librust-yeslogic-fontconfig-sys-dev:amd64 (3.0.1-1) ... 139s Setting up librust-sha2-dev:amd64 (0.10.8-1) ... 139s Setting up librust-hmac-dev:amd64 (0.12.1-1) ... 139s Setting up librust-rustix-dev:amd64 (0.38.32-1) ... 139s Setting up librust-wyz-dev:amd64 (0.5.1-1) ... 139s Setting up librust-bitvec-dev:amd64 (1.0.1-1) ... 139s Setting up librust-phf+uncased-dev:amd64 (0.11.2-1) ... 139s Setting up librust-value-bag-sval2-dev:amd64 (1.9.0-1) ... 139s Setting up librust-tempfile-dev:amd64 (3.10.1-1) ... 139s Setting up librust-eyre+default-dev:amd64 (0.6.12-1) ... 139s Setting up pybuild-plugin-autopkgtest (6.20241024) ... 139s Setting up librust-rusty-fork-dev:amd64 (0.3.0-1) ... 139s Setting up librust-hashbrown-dev:amd64 (0.14.5-5) ... 139s Setting up librust-rusty-fork+wait-timeout-dev:amd64 (0.3.0-1) ... 139s Setting up librust-terminal-size-dev:amd64 (0.3.0-2) ... 139s Setting up librust-indexmap-dev:amd64 (2.2.6-1) ... 139s Setting up librust-gimli-dev:amd64 (0.28.1-2) ... 139s Setting up librust-webp-dev:amd64 (0.2.6-1) ... 139s Setting up librust-memchr-dev:amd64 (2.7.4-1) ... 139s Setting up librust-futures-util-dev:amd64 (0.3.30-2) ... 139s Setting up librust-csv-core-dev:amd64 (0.1.11-1) ... 139s Setting up librust-futures-lite-dev:amd64 (2.3.0-2) ... 139s Setting up librust-csv-dev:amd64 (1.3.0-1) ... 139s Setting up librust-serde-json-dev:amd64 (1.0.128-1) ... 139s Setting up librust-async-executor-dev (1.13.1-1) ... 139s Setting up librust-futures-executor-dev:amd64 (0.3.30-1) ... 139s Setting up librust-value-bag-serde1-dev:amd64 (1.9.0-1) ... 139s Setting up librust-tinytemplate-dev:amd64 (1.2.1-1) ... 139s Setting up librust-futures-dev:amd64 (0.3.30-2) ... 139s Setting up librust-value-bag-dev:amd64 (1.9.0-1) ... 139s Setting up librust-log-dev:amd64 (0.4.22-1) ... 139s Setting up librust-kv-log-macro-dev (1.0.8-4) ... 139s Setting up librust-pathfinder-geometry-dev:amd64 (0.5.1-1) ... 139s Setting up librust-tracing-dev:amd64 (0.1.40-1) ... 139s Setting up librust-polling-dev:amd64 (3.4.0-1) ... 139s Setting up librust-aho-corasick-dev:amd64 (1.1.3-1) ... 139s Setting up librust-font-kit-dev:amd64 (0.11.0-2) ... 139s Setting up librust-async-io-dev:amd64 (2.3.3-4) ... 139s Setting up librust-blocking-dev (1.6.1-5) ... 139s Setting up librust-async-net-dev (2.0.0-4) ... 139s Setting up librust-rand-dev:amd64 (0.8.5-1) ... 139s Setting up librust-mio-dev:amd64 (1.0.2-2) ... 139s Setting up librust-wasm-bindgen-backend-dev:amd64 (0.2.87-1) ... 139s Setting up librust-twox-hash-dev:amd64 (1.6.3-1) ... 139s Setting up librust-proptest-dev:amd64 (1.5.0-2) ... 139s Setting up librust-wasm-bindgen-macro-support-dev:amd64 (0.2.87-1) ... 139s Setting up librust-regex-automata-dev:amd64 (0.4.7-1) ... 139s Setting up librust-wasm-bindgen-macro-support+spans-dev:amd64 (0.2.87-1) ... 139s Setting up librust-wasm-bindgen-macro-dev:amd64 (0.2.87-1) ... 139s Setting up librust-uuid-dev:amd64 (1.10.0-1) ... 139s Setting up librust-bstr-dev:amd64 (1.7.0-2build1) ... 139s Setting up librust-async-signal-dev:amd64 (0.2.10-1) ... 139s Setting up librust-bytecheck-dev:amd64 (0.6.12-1) ... 139s Setting up librust-postgres-protocol-dev:amd64 (0.6.6-2) ... 139s Setting up librust-async-fs-dev (2.1.2-4) ... 139s Setting up librust-wasm-bindgen-dev:amd64 (0.2.87-1) ... 139s Setting up librust-convert-case-dev:amd64 (0.6.0-2) ... 139s Setting up librust-regex-dev:amd64 (1.10.6-1) ... 139s Setting up librust-fancy-regex-dev:amd64 (0.11.0-2) ... 139s Setting up librust-async-process-dev (2.3.0-1) ... 139s Setting up librust-wasm-bindgen-macro+spans-dev:amd64 (0.2.87-1) ... 139s Setting up librust-rend-dev:amd64 (0.4.0-1) ... 139s Setting up librust-derive-more-0.99-dev:amd64 (0.99.18-1) ... 139s Setting up librust-env-logger-dev:amd64 (0.10.2-2) ... 139s Setting up librust-wasm-bindgen+spans-dev:amd64 (0.2.87-1) ... 139s Setting up librust-wasm-bindgen+default-dev:amd64 (0.2.87-1) ... 139s Setting up librust-rkyv-dev:amd64 (0.7.44-1) ... 139s Setting up librust-eui48-dev:amd64 (1.1.0-2) ... 139s Setting up librust-parse-zoneinfo-dev:amd64 (0.3.0-1) ... 139s Setting up librust-smol-dev (2.0.2-1) ... 139s Setting up librust-js-sys-dev:amd64 (0.3.64-1) ... 139s Setting up librust-num-complex-dev:amd64 (0.4.6-2) ... 139s Setting up librust-approx-dev:amd64 (0.5.1-1) ... 139s Setting up librust-ruzstd-dev:amd64 (0.5.0-1) ... 139s Setting up librust-web-sys-dev:amd64 (0.3.64-2) ... 139s Setting up librust-quickcheck-dev:amd64 (1.0.3-3) ... 139s Setting up librust-geo-types-dev:amd64 (0.7.11-2) ... 139s Setting up librust-deranged-dev:amd64 (0.3.11-1) ... 139s Setting up librust-num-bigint-dev:amd64 (0.4.6-1) ... 139s Setting up librust-num-rational-dev:amd64 (0.4.2-1) ... 139s Setting up librust-chrono-dev:amd64 (0.4.38-2) ... 139s Setting up librust-object-dev:amd64 (0.32.2-1) ... 139s Setting up librust-image-dev:amd64 (0.24.7-2) ... 139s Setting up librust-time-dev:amd64 (0.3.36-2) ... 139s Setting up librust-plotters-bitmap-dev:amd64 (0.3.3-3) ... 139s Setting up librust-postgres-types-dev:amd64 (0.2.6-2) ... 139s Setting up librust-addr2line-dev:amd64 (0.21.0-2) ... 139s Setting up librust-plotters-svg-dev:amd64 (0.3.5-1) ... 139s Setting up librust-rust-decimal-dev:amd64 (1.36.0-1) ... 139s Setting up librust-plotters-dev:amd64 (0.3.5-4) ... 139s Setting up librust-backtrace-dev:amd64 (0.3.69-2) ... 139s Setting up librust-tokio-dev:amd64 (1.39.3-3) ... 139s Setting up librust-async-global-executor-dev:amd64 (2.4.1-5) ... 139s Setting up librust-clap-builder-dev:amd64 (4.5.15-2) ... 139s Setting up librust-clap-dev:amd64 (4.5.16-1) ... 139s Setting up librust-async-std-dev (1.13.0-1) ... 139s Setting up librust-anyhow-dev:amd64 (1.0.86-1) ... 139s Setting up librust-criterion-dev (0.5.1-6) ... 139s Setting up librust-phf-generator-dev:amd64 (0.11.2-2) ... 139s Setting up librust-phf-codegen-dev:amd64 (0.11.2-1) ... 139s Setting up librust-chrono-tz-build-dev:amd64 (0.2.1-1) ... 139s Setting up librust-chrono-tz-dev:amd64 (0.8.6-2) ... 139s Setting up librust-pyo3-dev:amd64 (0.22.6-1) ... 139s Setting up autopkgtest-satdep (0) ... 139s Processing triggers for libc-bin (2.40-1ubuntu3) ... 139s Processing triggers for systemd (256.5-2ubuntu4) ... 139s Processing triggers for man-db (2.13.0-1) ... 140s Processing triggers for install-info (7.1.1-1) ... 153s (Reading database ... 102425 files and directories currently installed.) 153s Removing autopkgtest-satdep (0) ... 153s autopkgtest [20:33:32]: test pybuild-autopkgtest: pybuild-autopkgtest 153s autopkgtest [20:33:32]: test pybuild-autopkgtest: [----------------------- 154s pybuild-autopkgtest 154s I: pybuild base:311: cd /tmp/autopkgtest.rTBs3P/autopkgtest_tmp/build; python3.13 -m pytest tests 154s ============================= test session starts ============================== 154s platform linux -- Python 3.13.0, pytest-8.3.3, pluggy-1.5.0 154s rootdir: /tmp/autopkgtest.rTBs3P/autopkgtest_tmp/build 154s configfile: pyproject.toml 154s plugins: typeguard-4.4.1, hypothesis-6.119.3 154s collected 30 items 154s 736s tests/test_encoding.py FFFFFFFFFFFFFFFFFFFFFF [ 73%] 737s tests/test_misc.py F. [ 80%] 739s tests/test_offsets.py FF [ 86%] 741s tests/test_pickle.py F [ 90%] 743s tests/test_simple_public.py FF. [100%] 743s 743s =================================== FAILURES =================================== 743s _________________________________ test_simple __________________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_simple(): 743s > enc = tiktoken.get_encoding("gpt2") 743s 743s tests/test_encoding.py:15: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 743s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 743s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s _____________________________ test_simple_repeated _____________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_simple_repeated(): 743s > enc = tiktoken.get_encoding("gpt2") 743s 743s tests/test_encoding.py:32: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 743s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 743s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ______________________________ test_simple_regex _______________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_simple_regex(): 743s > enc = tiktoken.get_encoding("cl100k_base") 743s 743s tests/test_encoding.py:53: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ______________________________ test_basic_encode _______________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_basic_encode(): 743s > enc = tiktoken.get_encoding("r50k_base") 743s 743s tests/test_encoding.py:62: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ______________________________ test_encode_empty _______________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_encode_empty(): 743s > enc = tiktoken.get_encoding("r50k_base") 743s 743s tests/test_encoding.py:74: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ______________________________ test_encode_bytes _______________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_encode_bytes(): 743s > enc = tiktoken.get_encoding("cl100k_base") 743s 743s tests/test_encoding.py:79: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s _________________________ test_encode_surrogate_pairs __________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_encode_surrogate_pairs(): 743s > enc = tiktoken.get_encoding("cl100k_base") 743s 743s tests/test_encoding.py:84: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s _________________ test_catastrophically_repetitive[r50k_base] __________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'r50k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s def test_catastrophically_repetitive(make_enc: Callable[[], tiktoken.Encoding]): 743s > enc = make_enc() 743s 743s tests/test_encoding.py:96: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ________________ test_catastrophically_repetitive[cl100k_base] _________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'cl100k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s def test_catastrophically_repetitive(make_enc: Callable[[], tiktoken.Encoding]): 743s > enc = make_enc() 743s 743s tests/test_encoding.py:96: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s _______________________ test_basic_roundtrip[r50k_base] ________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, orE: pybuild pybuild:389: test: plugin pyproject failed with: exit code=1: cd /tmp/autopkgtest.rTBs3P/autopkgtest_tmp/build; python3.13 -m pytest tests 743s 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'r50k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s def test_basic_roundtrip(make_enc): 743s > enc = make_enc() 743s 743s tests/test_encoding.py:115: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ______________________ test_basic_roundtrip[cl100k_base] _______________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'cl100k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s def test_basic_roundtrip(make_enc): 743s > enc = make_enc() 743s 743s tests/test_encoding.py:115: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ________________________ test_hyp_roundtrip[r50k_base] _________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'r50k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s > @hypothesis.given(text=st.text()) 743s 743s tests/test_encoding.py:131: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s tests/test_encoding.py:134: in test_hyp_roundtrip 743s enc = make_enc() 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s E Falsifying example: test_hyp_roundtrip( 743s E make_enc=functools.partial(get_encoding, 'r50k_base'), 743s E text='', # or any other generated value 743s E ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s _______________________ test_hyp_roundtrip[cl100k_base] ________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s >I: pybuild base:311: cd /tmp/autopkgtest.rTBs3P/autopkgtest_tmp/build; python3.12 -m pytest tests 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'cl100k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s > @hypothesis.given(text=st.text()) 743s 743s tests/test_encoding.py:131: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s tests/test_encoding.py:134: in test_hyp_roundtrip 743s enc = make_enc() 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s E Falsifying example: test_hyp_roundtrip( 743s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 743s E text='', # or any other generated value 743s E ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ____________________ test_single_token_roundtrip[r50k_base] ____________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'r50k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s def test_single_token_roundtrip(make_enc: Callable[[], tiktoken.Encoding]): 743s > enc = make_enc() 743s 743s tests/test_encoding.py:141: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ___________________ test_single_token_roundtrip[cl100k_base] ___________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'cl100k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s def test_single_token_roundtrip(make_enc: Callable[[], tiktoken.Encoding]): 743s > enc = make_enc() 743s 743s tests/test_encoding.py:141: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ______________________________ test_special_token ______________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_special_token(): 743s > enc = tiktoken.get_encoding("cl100k_base") 743s 743s tests/test_encoding.py:157: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s _____________________ test_hyp_special_ordinary[r50k_base] _____________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'r50k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s > @hypothesis.given(text=st.text()) 743s 743s tests/test_encoding.py:208: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s tests/test_encoding.py:211: in test_hyp_special_ordinary 743s enc = make_enc() 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s E Falsifying example: test_hyp_special_ordinary( 743s E make_enc=functools.partial(get_encoding, 'r50k_base'), 743s E text='', # or any other generated value 743s E ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ____________________ test_hyp_special_ordinary[cl100k_base] ____________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'cl100k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s > @hypothesis.given(text=st.text()) 743s 743s tests/test_encoding.py:208: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s tests/test_encoding.py:211: in test_hyp_special_ordinary 743s enc = make_enc() 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s E Falsifying example: test_hyp_special_ordinary( 743s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 743s E text='', # or any other generated value 743s E ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s _________________________ test_batch_encode[r50k_base] _________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'r50k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s def test_batch_encode(make_enc: Callable[[], tiktoken.Encoding]): 743s > enc = make_enc() 743s 743s tests/test_encoding.py:222: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ________________________ test_batch_encode[cl100k_base] ________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'cl100k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s def test_batch_encode(make_enc: Callable[[], tiktoken.Encoding]): 743s > enc = make_enc() 743s 743s tests/test_encoding.py:222: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s _____________________ test_hyp_batch_roundtrip[r50k_base] ______________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'r50k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s > @hypothesis.given(batch=st.lists(st.text())) 743s 743s tests/test_encoding.py:237: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s tests/test_encoding.py:240: in test_hyp_batch_roundtrip 743s enc = make_enc() 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s E Falsifying example: test_hyp_batch_roundtrip( 743s E make_enc=functools.partial(get_encoding, 'r50k_base'), 743s E batch=[], # or any other generated value 743s E ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ____________________ test_hyp_batch_roundtrip[cl100k_base] _____________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'cl100k_base') 743s 743s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 743s > @hypothesis.given(batch=st.lists(st.text())) 743s 743s tests/test_encoding.py:237: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s tests/test_encoding.py:240: in test_hyp_batch_roundtrip 743s enc = make_enc() 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s E Falsifying example: test_hyp_batch_roundtrip( 743s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 743s E batch=[], # or any other generated value 743s E ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ___________________________ test_encoding_for_model ____________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_encoding_for_model(): 743s > enc = tiktoken.encoding_for_model("gpt2") 743s 743s tests/test_misc.py:8: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/model.py:105: in encoding_for_model 743s return get_encoding(encoding_name_for_model(model_name)) 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 743s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 743s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ________________________ test_hyp_offsets[cl100k_base] _________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s make_enc = functools.partial(, 'cl100k_base') 743s 743s @pytest.mark.parametrize("make_enc", SOME_ENCODING_FACTORIES) 743s > @hypothesis.given(data=st.data()) 743s 743s tests/test_offsets.py:29: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s tests/test_offsets.py:32: in test_hyp_offsets 743s enc = make_enc() 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s E Falsifying example: test_hyp_offsets( 743s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 743s E data=data(...), 743s E ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ______________________________ test_basic_offsets ______________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_basic_offsets(): 743s > enc = tiktoken.get_encoding("cl100k_base") 743s 743s tests/test_offsets.py:50: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s _________________________________ test_pickle __________________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_pickle(): 743s import pickle 743s 743s > enc_old = tiktoken.get_encoding("r50k_base") 743s 743s tests/test_pickle.py:7: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 743s mergeable_ranks = load_tiktoken_bpe( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 743s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s _________________________________ test_simple __________________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_simple(): 743s # Note that there are more actual tests, they're just not currently public :-) 743s > enc = tiktoken.get_encoding("gpt2") 743s 743s tests/test_simple_public.py:9: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 743s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 743s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s ___________________________ test_encoding_for_model ____________________________ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s > sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 743s raise err 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 743s source_address = None, socket_options = [(6, 1, 1)] 743s 743s def create_connection( 743s address: tuple[str, int], 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s source_address: tuple[str, int] | None = None, 743s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 743s ) -> socket.socket: 743s """Connect to *address* and return the socket object. 743s 743s Convenience function. Connect to *address* (a 2-tuple ``(host, 743s port)``) and return the socket object. Passing the optional 743s *timeout* parameter will set the timeout on the socket instance 743s before attempting to connect. If no *timeout* is supplied, the 743s global default timeout setting returned by :func:`socket.getdefaulttimeout` 743s is used. If *source_address* is set it must be a tuple of (host, port) 743s for the socket to bind as a source address before making the connection. 743s An host of '' or port 0 tells the OS to use the default. 743s """ 743s 743s host, port = address 743s if host.startswith("["): 743s host = host.strip("[]") 743s err = None 743s 743s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 743s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 743s # The original create_connection function always returns all records. 743s family = allowed_gai_family() 743s 743s try: 743s host.encode("idna") 743s except UnicodeError: 743s raise LocationParseError(f"'{host}', label empty or too long") from None 743s 743s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 743s af, socktype, proto, canonname, sa = res 743s sock = None 743s try: 743s sock = socket.socket(af, socktype, proto) 743s 743s # If provided, set socket level options before connecting. 743s _set_socket_options(sock, socket_options) 743s 743s if timeout is not _DEFAULT_TIMEOUT: 743s sock.settimeout(timeout) 743s if source_address: 743s sock.bind(source_address) 743s > sock.connect(sa) 743s E ConnectionRefusedError: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 743s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 743s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s redirect = False, assert_same_host = False 743s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 743s release_conn = False, chunked = False, body_pos = None, preload_content = False 743s decode_content = False, response_kw = {} 743s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 743s destination_scheme = None, conn = None, release_this_conn = True 743s http_tunnel_required = False, err = None, clean_exit = False 743s 743s def urlopen( # type: ignore[override] 743s self, 743s method: str, 743s url: str, 743s body: _TYPE_BODY | None = None, 743s headers: typing.Mapping[str, str] | None = None, 743s retries: Retry | bool | int | None = None, 743s redirect: bool = True, 743s assert_same_host: bool = True, 743s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 743s pool_timeout: int | None = None, 743s release_conn: bool | None = None, 743s chunked: bool = False, 743s body_pos: _TYPE_BODY_POSITION | None = None, 743s preload_content: bool = True, 743s decode_content: bool = True, 743s **response_kw: typing.Any, 743s ) -> BaseHTTPResponse: 743s """ 743s Get a connection from the pool and perform an HTTP request. This is the 743s lowest level call for making a request, so you'll need to specify all 743s the raw details. 743s 743s .. note:: 743s 743s More commonly, it's appropriate to use a convenience method 743s such as :meth:`request`. 743s 743s .. note:: 743s 743s `release_conn` will only behave as expected if 743s `preload_content=False` because we want to make 743s `preload_content=False` the default behaviour someday soon without 743s breaking backwards compatibility. 743s 743s :param method: 743s HTTP request method (such as GET, POST, PUT, etc.) 743s 743s :param url: 743s The URL to perform the request on. 743s 743s :param body: 743s Data to send in the request body, either :class:`str`, :class:`bytes`, 743s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 743s 743s :param headers: 743s Dictionary of custom headers to send, such as User-Agent, 743s If-None-Match, etc. If None, pool headers are used. If provided, 743s these headers completely replace any pool-specific headers. 743s 743s :param retries: 743s Configure the number of retries to allow before raising a 743s :class:`~urllib3.exceptions.MaxRetryError` exception. 743s 743s Pass ``None`` to retry until you receive a response. Pass a 743s :class:`~urllib3.util.retry.Retry` object for fine-grained control 743s over different types of retries. 743s Pass an integer number to retry connection errors that many times, 743s but no other types of errors. Pass zero to never retry. 743s 743s If ``False``, then retries are disabled and any exception is raised 743s immediately. Also, instead of raising a MaxRetryError on redirects, 743s the redirect response will be returned. 743s 743s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 743s 743s :param redirect: 743s If True, automatically handle redirects (status codes 301, 302, 743s 303, 307, 308). Each redirect counts as a retry. Disabling retries 743s will disable redirect, too. 743s 743s :param assert_same_host: 743s If ``True``, will make sure that the host of the pool requests is 743s consistent else will raise HostChangedError. When ``False``, you can 743s use the pool on an HTTP proxy and request foreign hosts. 743s 743s :param timeout: 743s If specified, overrides the default timeout for this one 743s request. It may be a float (in seconds) or an instance of 743s :class:`urllib3.util.Timeout`. 743s 743s :param pool_timeout: 743s If set and the pool is set to block=True, then this method will 743s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 743s connection is available within the time period. 743s 743s :param bool preload_content: 743s If True, the response's body will be preloaded into memory. 743s 743s :param bool decode_content: 743s If True, will attempt to decode the body based on the 743s 'content-encoding' header. 743s 743s :param release_conn: 743s If False, then the urlopen call will not release the connection 743s back into the pool once a response is received (but will release if 743s you read the entire contents of the response such as when 743s `preload_content=True`). This is useful if you're not preloading 743s the response's content immediately. You will need to call 743s ``r.release_conn()`` on the response ``r`` to return the connection 743s back into the pool. If None, it takes the value of ``preload_content`` 743s which defaults to ``True``. 743s 743s :param bool chunked: 743s If True, urllib3 will send the body using chunked transfer 743s encoding. Otherwise, urllib3 will send the body using the standard 743s content-length form. Defaults to False. 743s 743s :param int body_pos: 743s Position to seek to in file-like body in the event of a retry or 743s redirect. Typically this won't need to be set because urllib3 will 743s auto-populate the value when needed. 743s """ 743s parsed_url = parse_url(url) 743s destination_scheme = parsed_url.scheme 743s 743s if headers is None: 743s headers = self.headers 743s 743s if not isinstance(retries, Retry): 743s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 743s 743s if release_conn is None: 743s release_conn = preload_content 743s 743s # Check host 743s if assert_same_host and not self.is_same_host(url): 743s raise HostChangedError(self, url, retries) 743s 743s # Ensure that the URL we're connecting to is properly encoded 743s if url.startswith("/"): 743s url = to_str(_encode_target(url)) 743s else: 743s url = to_str(parsed_url.url) 743s 743s conn = None 743s 743s # Track whether `conn` needs to be released before 743s # returning/raising/recursing. Update this variable if necessary, and 743s # leave `release_conn` constant throughout the function. That way, if 743s # the function recurses, the original value of `release_conn` will be 743s # passed down into the recursive call, and its value will be respected. 743s # 743s # See issue #651 [1] for details. 743s # 743s # [1] 743s release_this_conn = release_conn 743s 743s http_tunnel_required = connection_requires_http_tunnel( 743s self.proxy, self.proxy_config, destination_scheme 743s ) 743s 743s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 743s # have to copy the headers dict so we can safely change it without those 743s # changes being reflected in anyone else's copy. 743s if not http_tunnel_required: 743s headers = headers.copy() # type: ignore[attr-defined] 743s headers.update(self.proxy_headers) # type: ignore[union-attr] 743s 743s # Must keep the exception bound to a separate variable or else Python 3 743s # complains about UnboundLocalError. 743s err = None 743s 743s # Keep track of whether we cleanly exited the except block. This 743s # ensures we do proper cleanup in finally. 743s clean_exit = False 743s 743s # Rewind body position, if needed. Record current position 743s # for future rewinds in the event of a redirect/retry. 743s body_pos = set_file_position(body, body_pos) 743s 743s try: 743s # Request a connection from the queue. 743s timeout_obj = self._get_timeout(timeout) 743s conn = self._get_conn(timeout=pool_timeout) 743s 743s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 743s 743s # Is this a closed/new connection that requires CONNECT tunnelling? 743s if self.proxy is not None and http_tunnel_required and conn.is_closed: 743s try: 743s self._prepare_proxy(conn) 743s except (BaseSSLError, OSError, SocketTimeout) as e: 743s self._raise_timeout( 743s err=e, url=self.proxy.url, timeout_value=conn.timeout 743s ) 743s raise 743s 743s # If we're going to release the connection in ``finally:``, then 743s # the response doesn't need to know about the connection. Otherwise 743s # it will also try to release it and we'll have a double-release 743s # mess. 743s response_conn = conn if not release_conn else None 743s 743s # Make the request on the HTTPConnection object 743s > response = self._make_request( 743s conn, 743s method, 743s url, 743s timeout=timeout_obj, 743s body=body, 743s headers=headers, 743s chunked=chunked, 743s retries=retries, 743s response_conn=response_conn, 743s preload_content=preload_content, 743s decode_content=decode_content, 743s **response_kw, 743s ) 743s 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 743s raise new_e 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 743s self._validate_conn(conn) 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 743s conn.connect() 743s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 743s self.sock = sock = self._new_conn() 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s 743s def _new_conn(self) -> socket.socket: 743s """Establish a socket connection and set nodelay settings on it. 743s 743s :return: New socket connection. 743s """ 743s try: 743s sock = connection.create_connection( 743s (self._dns_host, self.port), 743s self.timeout, 743s source_address=self.source_address, 743s socket_options=self.socket_options, 743s ) 743s except socket.gaierror as e: 743s raise NameResolutionError(self.host, self, e) from e 743s except SocketTimeout as e: 743s raise ConnectTimeoutError( 743s self, 743s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 743s ) from e 743s 743s except OSError as e: 743s > raise NewConnectionError( 743s self, f"Failed to establish a new connection: {e}" 743s ) from e 743s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 743s 743s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 743s 743s The above exception was the direct cause of the following exception: 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s > resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:667: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 743s retries = retries.increment( 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 743s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 743s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 743s _pool = 743s _stacktrace = 743s 743s def increment( 743s self, 743s method: str | None = None, 743s url: str | None = None, 743s response: BaseHTTPResponse | None = None, 743s error: Exception | None = None, 743s _pool: ConnectionPool | None = None, 743s _stacktrace: TracebackType | None = None, 743s ) -> Retry: 743s """Return a new Retry object with incremented retry counters. 743s 743s :param response: A response object, or None, if the server did not 743s return a response. 743s :type response: :class:`~urllib3.response.BaseHTTPResponse` 743s :param Exception error: An error encountered during the request, or 743s None if the response was received successfully. 743s 743s :return: A new ``Retry`` object. 743s """ 743s if self.total is False and error: 743s # Disabled, indicate to re-raise the error. 743s raise reraise(type(error), error, _stacktrace) 743s 743s total = self.total 743s if total is not None: 743s total -= 1 743s 743s connect = self.connect 743s read = self.read 743s redirect = self.redirect 743s status_count = self.status 743s other = self.other 743s cause = "unknown" 743s status = None 743s redirect_location = None 743s 743s if error and self._is_connection_error(error): 743s # Connect retry? 743s if connect is False: 743s raise reraise(type(error), error, _stacktrace) 743s elif connect is not None: 743s connect -= 1 743s 743s elif error and self._is_read_error(error): 743s # Read retry? 743s if read is False or method is None or not self._is_method_retryable(method): 743s raise reraise(type(error), error, _stacktrace) 743s elif read is not None: 743s read -= 1 743s 743s elif error: 743s # Other retry? 743s if other is not None: 743s other -= 1 743s 743s elif response and response.get_redirect_location(): 743s # Redirect retry? 743s if redirect is not None: 743s redirect -= 1 743s cause = "too many redirects" 743s response_redirect_location = response.get_redirect_location() 743s if response_redirect_location: 743s redirect_location = response_redirect_location 743s status = response.status 743s 743s else: 743s # Incrementing because of a server error like a 500 in 743s # status_forcelist and the given method is in the allowed_methods 743s cause = ResponseError.GENERIC_ERROR 743s if response and response.status: 743s if status_count is not None: 743s status_count -= 1 743s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 743s status = response.status 743s 743s history = self.history + ( 743s RequestHistory(method, url, error, status, redirect_location), 743s ) 743s 743s new_retry = self.new( 743s total=total, 743s connect=connect, 743s read=read, 743s redirect=redirect, 743s status=status_count, 743s other=other, 743s history=history, 743s ) 743s 743s if new_retry.is_exhausted(): 743s reason = error or ResponseError(cause) 743s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 743s 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')) 743s 743s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 743s 743s During handling of the above exception, another exception occurred: 743s 743s def test_encoding_for_model(): 743s > enc = tiktoken.encoding_for_model("gpt2") 743s 743s tests/test_simple_public.py:26: 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s /usr/lib/python3/dist-packages/tiktoken/model.py:105: in encoding_for_model 743s return get_encoding(encoding_name_for_model(model_name)) 743s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 743s enc = Encoding(**constructor()) 743s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 743s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 743s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 743s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 743s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 743s contents = read_file(blobpath) 743s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 743s resp = requests.get(blobpath) 743s /usr/lib/python3/dist-packages/requests/api.py:73: in get 743s return request("get", url, params=params, **kwargs) 743s /usr/lib/python3/dist-packages/requests/api.py:59: in request 743s return session.request(method=method, url=url, **kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 743s resp = self.send(prep, **send_kwargs) 743s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 743s r = adapter.send(request, **kwargs) 743s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 743s 743s self = 743s request = , stream = False 743s timeout = Timeout(connect=None, read=None, total=None), verify = True 743s cert = None, proxies = OrderedDict() 743s 743s def send( 743s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 743s ): 743s """Sends PreparedRequest object. Returns Response object. 743s 743s :param request: The :class:`PreparedRequest ` being sent. 743s :param stream: (optional) Whether to stream the request content. 743s :param timeout: (optional) How long to wait for the server to send 743s data before giving up, as a float, or a :ref:`(connect timeout, 743s read timeout) ` tuple. 743s :type timeout: float or tuple or urllib3 Timeout object 743s :param verify: (optional) Either a boolean, in which case it controls whether 743s we verify the server's TLS certificate, or a string, in which case it 743s must be a path to a CA bundle to use 743s :param cert: (optional) Any user-provided SSL certificate to be trusted. 743s :param proxies: (optional) The proxies dictionary to apply to the request. 743s :rtype: requests.Response 743s """ 743s 743s try: 743s conn = self.get_connection_with_tls_context( 743s request, verify, proxies=proxies, cert=cert 743s ) 743s except LocationValueError as e: 743s raise InvalidURL(e, request=request) 743s 743s self.cert_verify(conn, request.url, verify, cert) 743s url = self.request_url(request, proxies) 743s self.add_headers( 743s request, 743s stream=stream, 743s timeout=timeout, 743s verify=verify, 743s cert=cert, 743s proxies=proxies, 743s ) 743s 743s chunked = not (request.body is None or "Content-Length" in request.headers) 743s 743s if isinstance(timeout, tuple): 743s try: 743s connect, read = timeout 743s timeout = TimeoutSauce(connect=connect, read=read) 743s except ValueError: 743s raise ValueError( 743s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 743s f"or a single float to set both timeouts to the same value." 743s ) 743s elif isinstance(timeout, TimeoutSauce): 743s pass 743s else: 743s timeout = TimeoutSauce(connect=timeout, read=timeout) 743s 743s try: 743s resp = conn.urlopen( 743s method=request.method, 743s url=url, 743s body=request.body, 743s headers=request.headers, 743s redirect=False, 743s assert_same_host=False, 743s preload_content=False, 743s decode_content=False, 743s retries=self.max_retries, 743s timeout=timeout, 743s chunked=chunked, 743s ) 743s 743s except (ProtocolError, OSError) as err: 743s raise ConnectionError(err, request=request) 743s 743s except MaxRetryError as e: 743s if isinstance(e.reason, ConnectTimeoutError): 743s # TODO: Remove this in 3.0.0: see #2811 743s if not isinstance(e.reason, NewConnectionError): 743s raise ConnectTimeout(e, request=request) 743s 743s if isinstance(e.reason, ResponseError): 743s raise RetryError(e, request=request) 743s 743s if isinstance(e.reason, _ProxyError): 743s raise ProxyError(e, request=request) 743s 743s if isinstance(e.reason, _SSLError): 743s # This branch is for urllib3 v1.22 and later. 743s raise SSLError(e, request=request) 743s 743s > raise ConnectionError(e, request=request) 743s 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')) 743s 743s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 743s =========================== short test summary info ============================ 743s FAILED tests/test_encoding.py::test_simple - requests.exceptions.ConnectionEr... 743s FAILED tests/test_encoding.py::test_simple_repeated - requests.exceptions.Con... 743s FAILED tests/test_encoding.py::test_simple_regex - requests.exceptions.Connec... 743s FAILED tests/test_encoding.py::test_basic_encode - requests.exceptions.Connec... 743s FAILED tests/test_encoding.py::test_encode_empty - requests.exceptions.Connec... 743s FAILED tests/test_encoding.py::test_encode_bytes - requests.exceptions.Connec... 743s FAILED tests/test_encoding.py::test_encode_surrogate_pairs - requests.excepti... 743s FAILED tests/test_encoding.py::test_catastrophically_repetitive[r50k_base] - ... 743s FAILED tests/test_encoding.py::test_catastrophically_repetitive[cl100k_base] 743s FAILED tests/test_encoding.py::test_basic_roundtrip[r50k_base] - requests.exc... 743s FAILED tests/test_encoding.py::test_basic_roundtrip[cl100k_base] - requests.e... 743s FAILED tests/test_encoding.py::test_hyp_roundtrip[r50k_base] - requests.excep... 743s FAILED tests/test_encoding.py::test_hyp_roundtrip[cl100k_base] - requests.exc... 743s FAILED tests/test_encoding.py::test_single_token_roundtrip[r50k_base] - reque... 743s FAILED tests/test_encoding.py::test_single_token_roundtrip[cl100k_base] - req... 743s FAILED tests/test_encoding.py::test_special_token - requests.exceptions.Conne... 743s FAILED tests/test_encoding.py::test_hyp_special_ordinary[r50k_base] - request... 743s FAILED tests/test_encoding.py::test_hyp_special_ordinary[cl100k_base] - reque... 743s FAILED tests/test_encoding.py::test_batch_encode[r50k_base] - requests.except... 743s FAILED tests/test_encoding.py::test_batch_encode[cl100k_base] - requests.exce... 743s FAILED tests/test_encoding.py::test_hyp_batch_roundtrip[r50k_base] - requests... 743s FAILED tests/test_encoding.py::test_hyp_batch_roundtrip[cl100k_base] - reques... 743s FAILED tests/test_misc.py::test_encoding_for_model - requests.exceptions.Conn... 743s FAILED tests/test_offsets.py::test_hyp_offsets[cl100k_base] - requests.except... 743s FAILED tests/test_offsets.py::test_basic_offsets - requests.exceptions.Connec... 743s FAILED tests/test_pickle.py::test_pickle - requests.exceptions.ConnectionErro... 743s FAILED tests/test_simple_public.py::test_simple - requests.exceptions.Connect... 743s FAILED tests/test_simple_public.py::test_encoding_for_model - requests.except... 743s =================== 28 failed, 2 passed in 588.76s (0:09:48) =================== 743s ============================= test session starts ============================== 743s platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0 743s rootdir: /tmp/autopkgtest.rTBs3P/autopkgtest_tmp/build 743s configfile: pyproject.toml 743s plugins: typeguard-4.4.1, hypothesis-6.119.3 743s collected 30 items 743s 771s tests/test_encoding.py FFFFFFFFFFFFFFFFFFFFFF [ 73%] 772s tests/test_misc.py F. [ 80%] 774s tests/test_offsets.py FF [ 86%] 775s tests/test_pickle.py F [ 90%] 777s tests/test_simple_public.py FF. [100%] 777s 777s =================================== FAILURES =================================== 777s _________________________________ test_simple __________________________________ 777s 777s self = 777s 777s def _new_conn(self) -> socket.socket: 777s """Establish a socket connection and set nodelay settings on it. 777s 777s :return: New socket connection. 777s """ 777s try: 777s > sock = connection.create_connection( 777s (self._dns_host, self.port), 777s self.timeout, 777s source_address=self.source_address, 777s socket_options=self.socket_options, 777s ) 777s 777s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 777s raise err 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 777s source_address = None, socket_options = [(6, 1, 1)] 777s 777s def create_connection( 777s address: tuple[str, int], 777s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 777s source_address: tuple[str, int] | None = None, 777s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 777s ) -> socket.socket: 777s """Connect to *address* and return the socket object. 777s 777s Convenience function. Connect to *address* (a 2-tuple ``(host, 777s port)``) and return the socket object. Passing the optional 777s *timeout* parameter will set the timeout on the socket instance 777s before attempting to connect. If no *timeout* is supplied, the 777s global default timeout setting returned by :func:`socket.getdefaulttimeout` 777s is used. If *source_address* is set it must be a tuple of (host, port) 777s for the socket to bind as a source address before making the connection. 777s An host of '' or port 0 tells the OS to use the default. 777s """ 777s 777s host, port = address 777s if host.startswith("["): 777s host = host.strip("[]") 777s err = None 777s 777s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 777s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 777s # The original create_connection function always returns all records. 777s family = allowed_gai_family() 777s 777s try: 777s host.encode("idna") 777s except UnicodeError: 777s raise LocationParseError(f"'{host}', label empty or too long") from None 777s 777s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 777s af, socktype, proto, canonname, sa = res 777s sock = None 777s try: 777s sock = socket.socket(af, socktype, proto) 777s 777s # If provided, set socket level options before connecting. 777s _set_socket_options(sock, socket_options) 777s 777s if timeout is not _DEFAULT_TIMEOUT: 777s sock.settimeout(timeout) 777s if source_address: 777s sock.bind(source_address) 777s > sock.connect(sa) 777s E ConnectionRefusedError: [Errno 111] Connection refused 777s 777s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 777s 777s The above exception was the direct cause of the following exception: 777s 777s self = 777s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 777s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 777s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 777s redirect = False, assert_same_host = False 777s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 777s release_conn = False, chunked = False, body_pos = None, preload_content = False 777s decode_content = False, response_kw = {} 777s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 777s destination_scheme = None, conn = None, release_this_conn = True 777s http_tunnel_required = False, err = None, clean_exit = False 777s 777s def urlopen( # type: ignore[override] 777s self, 777s method: str, 777s url: str, 777s body: _TYPE_BODY | None = None, 777s headers: typing.Mapping[str, str] | None = None, 777s retries: Retry | bool | int | None = None, 777s redirect: bool = True, 777s assert_same_host: bool = True, 777s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 777s pool_timeout: int | None = None, 777s release_conn: bool | None = None, 777s chunked: bool = False, 777s body_pos: _TYPE_BODY_POSITION | None = None, 777s preload_content: bool = True, 777s decode_content: bool = True, 777s **response_kw: typing.Any, 777s ) -> BaseHTTPResponse: 777s """ 777s Get a connection from the pool and perform an HTTP request. This is the 777s lowest level call for making a request, so you'll need to specify all 777s the raw details. 777s 777s .. note:: 777s 777s More commonly, it's appropriate to use a convenience method 777s such as :meth:`request`. 777s 777s .. note:: 777s 777s `release_conn` will only behave as expected if 777s `preload_content=False` because we want to make 777s `preload_content=False` the default behaviour someday soon without 777s breaking backwards compatibility. 777s 777s :param method: 777s HTTP request method (such as GET, POST, PUT, etc.) 777s 777s :param url: 777s The URL to perform the request on. 777s 777s :param body: 777s Data to send in the request body, either :class:`str`, :class:`bytes`, 777s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 777s 777s :param headers: 777s Dictionary of custom headers to send, such as User-Agent, 777s If-None-Match, etc. If None, pool headers are used. If provided, 777s these headers completely replace any pool-specific headers. 777s 777s :param retries: 777s Configure the number of retries to allow before raising a 777s :class:`~urllib3.exceptions.MaxRetryError` exception. 777s 777s Pass ``None`` to retry until you receive a response. Pass a 777s :class:`~urllib3.util.retry.Retry` object for fine-grained control 777s over different types of retries. 777s Pass an integer number to retry connection errors that many times, 777s but no other types of errors. Pass zero to never retry. 777s 777s If ``False``, then retries are disabled and any exception is raised 777s immediately. Also, instead of raising a MaxRetryError on redirects, 777s the redirect response will be returned. 777s 777s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 777s 777s :param redirect: 777s If True, automatically handle redirects (status codes 301, 302, 777s 303, 307, 308). Each redirect counts as a retry. Disabling retries 777s will disable redirect, too. 777s 777s :param assert_same_host: 777s If ``True``, will make sure that the host of the pool requests is 777s consistent else will raise HostChangedError. When ``False``, you can 777s use the pool on an HTTP proxy and request foreign hosts. 777s 777s :param timeout: 777s If specified, overrides the default timeout for this one 777s request. It may be a float (in seconds) or an instance of 777s :class:`urllib3.util.Timeout`. 777s 777s :param pool_timeout: 777s If set and the pool is set to block=True, then this method will 777s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 777s connection is available within the time period. 777s 777s :param bool preload_content: 777s If True, the response's body will be preloaded into memory. 777s 777s :param bool decode_content: 777s If True, will attempt to decode the body based on the 777s 'content-encoding' header. 777s 777s :param release_conn: 777s If False, then the urlopen call will not release the connection 777s back into the pool once a response is received (but will release if 777s you read the entire contents of the response such as when 777s `preload_content=True`). This is useful if you're not preloading 777s the response's content immediately. You will need to call 777s ``r.release_conn()`` on the response ``r`` to return the connection 777s back into the pool. If None, it takes the value of ``preload_content`` 777s which defaults to ``True``. 777s 777s :param bool chunked: 777s If True, urllib3 will send the body using chunked transfer 777s encoding. Otherwise, urllib3 will send the body using the standard 777s content-length form. Defaults to False. 777s 777s :param int body_pos: 777s Position to seek to in file-like body in the event of a retry or 777s redirect. Typically this won't need to be set because urllib3 will 777s auto-populate the value when needed. 777s """ 777s parsed_url = parse_url(url) 777s destination_scheme = parsed_url.scheme 777s 777s if headers is None: 777s headers = self.headers 777s 777s if not isinstance(retries, Retry): 777s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 777s 777s if release_conn is None: 777s release_conn = preload_content 777s 777s # Check host 777s if assert_same_host and not self.is_same_host(url): 777s raise HostChangedError(self, url, retries) 777s 777s # Ensure that the URL we're connecting to is properly encoded 777s if url.startswith("/"): 777s url = to_str(_encode_target(url)) 777s else: 777s url = to_str(parsed_url.url) 777s 777s conn = None 777s 777s # Track whether `conn` needs to be released before 777s # returning/raising/recursing. Update this variable if necessary, and 777s # leave `release_conn` constant throughout the function. That way, if 777s # the function recurses, the original value of `release_conn` will be 777s # passed down into the recursive call, and its value will be respected. 777s # 777s # See issue #651 [1] for details. 777s # 777s # [1] 777s release_this_conn = release_conn 777s 777s http_tunnel_required = connection_requires_http_tunnel( 777s self.proxy, self.proxy_config, destination_scheme 777s ) 777s 777s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 777s # have to copy the headers dict so we can safely change it without those 777s # changes being reflected in anyone else's copy. 777s if not http_tunnel_required: 777s headers = headers.copy() # type: ignore[attr-defined] 777s headers.update(self.proxy_headers) # type: ignore[union-attr] 777s 777s # Must keep the exception bound to a separate variable or else Python 3 777s # complains about UnboundLocalError. 777s err = None 777s 777s # Keep track of whether we cleanly exited the except block. This 777s # ensures we do proper cleanup in finally. 777s clean_exit = False 777s 777s # Rewind body position, if needed. Record current position 777s # for future rewinds in the event of a redirect/retry. 777s body_pos = set_file_position(body, body_pos) 777s 777s try: 777s # Request a connection from the queue. 777s timeout_obj = self._get_timeout(timeout) 777s conn = self._get_conn(timeout=pool_timeout) 777s 777s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 777s 777s # Is this a closed/new connection that requires CONNECT tunnelling? 777s if self.proxy is not None and http_tunnel_required and conn.is_closed: 777s try: 777s self._prepare_proxy(conn) 777s except (BaseSSLError, OSError, SocketTimeout) as e: 777s self._raise_timeout( 777s err=e, url=self.proxy.url, timeout_value=conn.timeout 777s ) 777s raise 777s 777s # If we're going to release the connection in ``finally:``, then 777s # the response doesn't need to know about the connection. Otherwise 777s # it will also try to release it and we'll have a double-release 777s # mess. 777s response_conn = conn if not release_conn else None 777s 777s # Make the request on the HTTPConnection object 777s > response = self._make_request( 777s conn, 777s method, 777s url, 777s timeout=timeout_obj, 777s body=body, 777s headers=headers, 777s chunked=chunked, 777s retries=retries, 777s response_conn=response_conn, 777s preload_content=preload_content, 777s decode_content=decode_content, 777s **response_kw, 777s ) 777s 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 777s raise new_e 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 777s self._validate_conn(conn) 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 777s conn.connect() 777s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 777s self.sock = sock = self._new_conn() 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s self = 777s 777s def _new_conn(self) -> socket.socket: 777s """Establish a socket connection and set nodelay settings on it. 777s 777s :return: New socket connection. 777s """ 777s try: 777s sock = connection.create_connection( 777s (self._dns_host, self.port), 777s self.timeout, 777s source_address=self.source_address, 777s socket_options=self.socket_options, 777s ) 777s except socket.gaierror as e: 777s raise NameResolutionError(self.host, self, e) from e 777s except SocketTimeout as e: 777s raise ConnectTimeoutError( 777s self, 777s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 777s ) from e 777s 777s except OSError as e: 777s > raise NewConnectionError( 777s self, f"Failed to establish a new connection: {e}" 777s ) from e 777s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 777s 777s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 777s 777s The above exception was the direct cause of the following exception: 777s 777s self = 777s request = , stream = False 777s timeout = Timeout(connect=None, read=None, total=None), verify = True 777s cert = None, proxies = OrderedDict() 777s 777s def send( 777s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 777s ): 777s """Sends PreparedRequest object. Returns Response object. 777s 777s :param request: The :class:`PreparedRequest ` being sent. 777s :param stream: (optional) Whether to stream the request content. 777s :param timeout: (optional) How long to wait for the server to send 777s data before giving up, as a float, or a :ref:`(connect timeout, 777s read timeout) ` tuple. 777s :type timeout: float or tuple or urllib3 Timeout object 777s :param verify: (optional) Either a boolean, in which case it controls whether 777s we verify the server's TLS certificate, or a string, in which case it 777s must be a path to a CA bundle to use 777s :param cert: (optional) Any user-provided SSL certificate to be trusted. 777s :param proxies: (optional) The proxies dictionary to apply to the request. 777s :rtype: requests.Response 777s """ 777s 777s try: 777s conn = self.get_connection_with_tls_context( 777s request, verify, proxies=proxies, cert=cert 777s ) 777s except LocationValueError as e: 777s raise InvalidURL(e, request=request) 777s 777s self.cert_verify(conn, request.url, verify, cert) 777s url = self.request_url(request, proxies) 777s self.add_headers( 777s request, 777s stream=stream, 777s timeout=timeout, 777s verify=verify, 777s cert=cert, 777s proxies=proxies, 777s ) 777s 777s chunked = not (request.body is None or "Content-Length" in request.headers) 777s 777s if isinstance(timeout, tuple): 777s try: 777s connect, read = timeout 777s timeout = TimeoutSauce(connect=connect, read=read) 777s except ValueError: 777s raise ValueError( 777s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 777s f"or a single float to set both timeouts to the same value." 777s ) 777s elif isinstance(timeout, TimeoutSauce): 777s pass 777s else: 777s timeout = TimeoutSauce(connect=timeout, read=timeout) 777s 777s try: 777s > resp = conn.urlopen( 777s method=request.method, 777s url=url, 777s body=request.body, 777s headers=request.headers, 777s redirect=False, 777s assert_same_host=False, 777s preload_content=False, 777s decode_content=False, 777s retries=self.max_retries, 777s timeout=timeout, 777s chunked=chunked, 777s ) 777s 777s /usr/lib/python3/dist-packages/requests/adapters.py:667: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 777s retries = retries.increment( 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 777s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 777s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 777s _pool = 777s _stacktrace = 777s 777s def increment( 777s self, 777s method: str | None = None, 777s url: str | None = None, 777s response: BaseHTTPResponse | None = None, 777s error: Exception | None = None, 777s _pool: ConnectionPool | None = None, 777s _stacktrace: TracebackType | None = None, 777s ) -> Retry: 777s """Return a new Retry object with incremented retry counters. 777s 777s :param response: A response object, or None, if the server did not 777s return a response. 777s :type response: :class:`~urllib3.response.BaseHTTPResponse` 777s :param Exception error: An error encountered during the request, or 777s None if the response was received successfully. 777s 777s :return: A new ``Retry`` object. 777s """ 777s if self.total is False and error: 777s # Disabled, indicate to re-raise the error. 777s raise reraise(type(error), error, _stacktrace) 777s 777s total = self.total 777s if total is not None: 777s total -= 1 777s 777s connect = self.connect 777s read = self.read 777s redirect = self.redirect 777s status_count = self.status 777s other = self.other 777s cause = "unknown" 777s status = None 777s redirect_location = None 777s 777s if error and self._is_connection_error(error): 777s # Connect retry? 777s if connect is False: 777s raise reraise(type(error), error, _stacktrace) 777s elif connect is not None: 777s connect -= 1 777s 777s elif error and self._is_read_error(error): 777s # Read retry? 777s if read is False or method is None or not self._is_method_retryable(method): 777s raise reraise(type(error), error, _stacktrace) 777s elif read is not None: 777s read -= 1 777s 777s elif error: 777s # Other retry? 777s if other is not None: 777s other -= 1 777s 777s elif response and response.get_redirect_location(): 777s # Redirect retry? 777s if redirect is not None: 777s redirect -= 1 777s cause = "too many redirects" 777s response_redirect_location = response.get_redirect_location() 777s if response_redirect_location: 777s redirect_location = response_redirect_location 777s status = response.status 777s 777s else: 777s # Incrementing because of a server error like a 500 in 777s # status_forcelist and the given method is in the allowed_methods 777s cause = ResponseError.GENERIC_ERROR 777s if response and response.status: 777s if status_count is not None: 777s status_count -= 1 777s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 777s status = response.status 777s 777s history = self.history + ( 777s RequestHistory(method, url, error, status, redirect_location), 777s ) 777s 777s new_retry = self.new( 777s total=total, 777s connect=connect, 777s read=read, 777s redirect=redirect, 777s status=status_count, 777s other=other, 777s history=history, 777s ) 777s 777s if new_retry.is_exhausted(): 777s reason = error or ResponseError(cause) 777s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 777s 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')) 777s 777s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 777s 777s During handling of the above exception, another exception occurred: 777s 777s def test_simple(): 777s > enc = tiktoken.get_encoding("gpt2") 777s 777s tests/test_encoding.py:15: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 777s enc = Encoding(**constructor()) 777s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 777s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 777s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 777s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 777s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 777s contents = read_file(blobpath) 777s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 777s resp = requests.get(blobpath) 777s /usr/lib/python3/dist-packages/requests/api.py:73: in get 777s return request("get", url, params=params, **kwargs) 777s /usr/lib/python3/dist-packages/requests/api.py:59: in request 777s return session.request(method=method, url=url, **kwargs) 777s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 777s resp = self.send(prep, **send_kwargs) 777s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 777s r = adapter.send(request, **kwargs) 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s self = 777s request = , stream = False 777s timeout = Timeout(connect=None, read=None, total=None), verify = True 777s cert = None, proxies = OrderedDict() 777s 777s def send( 777s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 777s ): 777s """Sends PreparedRequest object. Returns Response object. 777s 777s :param request: The :class:`PreparedRequest ` being sent. 777s :param stream: (optional) Whether to stream the request content. 777s :param timeout: (optional) How long to wait for the server to send 777s data before giving up, as a float, or a :ref:`(connect timeout, 777s read timeout) ` tuple. 777s :type timeout: float or tuple or urllib3 Timeout object 777s :param verify: (optional) Either a boolean, in which case it controls whether 777s we verify the server's TLS certificate, or a string, in which case it 777s must be a path to a CA bundle to use 777s :param cert: (optional) Any user-provided SSL certificate to be trusted. 777s :param proxies: (optional) The proxies dictionary to apply to the request. 777s :rtype: requests.Response 777s """ 777s 777s try: 777s conn = self.get_connection_with_tls_context( 777s request, verify, proxies=proxies, cert=cert 777s ) 777s except LocationValueError as e: 777s raise InvalidURL(e, request=request) 777s 777s self.cert_verify(conn, request.url, verify, cert) 777s url = self.request_url(request, proxies) 777s self.add_headers( 777s request, 777s stream=stream, 777s timeout=timeout, 777s verify=verify, 777s cert=cert, 777s proxies=proxies, 777s ) 777s 777s chunked = not (request.body is None or "Content-Length" in request.headers) 777s 777s if isinstance(timeout, tuple): 777s try: 777s connect, read = timeout 777s timeout = TimeoutSauce(connect=connect, read=read) 777s except ValueError: 777s raise ValueError( 777s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 777s f"or a single float to set both timeouts to the same value." 777s ) 777s elif isinstance(timeout, TimeoutSauce): 777s pass 777s else: 777s timeout = TimeoutSauce(connect=timeout, read=timeout) 777s 777s try: 777s resp = conn.urlopen( 777s method=request.method, 777s url=url, 777s body=request.body, 777s headers=request.headers, 777s redirect=False, 777s assert_same_host=False, 777s preload_content=False, 777s decode_content=False, 777s retries=self.max_retries, 777s timeout=timeout, 777s chunked=chunked, 777s ) 777s 777s except (ProtocolError, OSError) as err: 777s raise ConnectionError(err, request=request) 777s 777s except MaxRetryError as e: 777s if isinstance(e.reason, ConnectTimeoutError): 777s # TODO: Remove this in 3.0.0: see #2811 777s if not isinstance(e.reason, NewConnectionError): 777s raise ConnectTimeout(e, request=request) 777s 777s if isinstance(e.reason, ResponseError): 777s raise RetryError(e, request=request) 777s 777s if isinstance(e.reason, _ProxyError): 777s raise ProxyError(e, request=request) 777s 777s if isinstance(e.reason, _SSLError): 777s # This branch is for urllib3 v1.22 and later. 777s raise SSLError(e, request=request) 777s 777s > raise ConnectionError(e, request=request) 777s 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')) 777s 777s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 777s _____________________________ test_simple_repeated _____________________________ 777s 777s self = 777s 777s def _new_conn(self) -> socket.socket: 777s """Establish a socket connection and set nodelay settings on it. 777s 777s :return: New socket connection. 777s """ 777s try: 777s > sock = connection.create_connection( 777s (self._dns_host, self.port), 777s self.timeout, 777s source_address=self.source_address, 777s socket_options=self.socket_options, 777s ) 777s 777s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 777s raise err 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 777s source_address = None, socket_options = [(6, 1, 1)] 777s 777s def create_connection( 777s address: tuple[str, int], 777s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 777s source_address: tuple[str, int] | None = None, 777s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 777s ) -> socket.socket: 777s """Connect to *address* and return the socket object. 777s 777s Convenience function. Connect to *address* (a 2-tuple ``(host, 777s port)``) and return the socket object. Passing the optional 777s *timeout* parameter will set the timeout on the socket instance 777s before attempting to connect. If no *timeout* is supplied, the 777s global default timeout setting returned by :func:`socket.getdefaulttimeout` 777s is used. If *source_address* is set it must be a tuple of (host, port) 777s for the socket to bind as a source address before making the connection. 777s An host of '' or port 0 tells the OS to use the default. 777s """ 777s 777s host, port = address 777s if host.startswith("["): 777s host = host.strip("[]") 777s err = None 777s 777s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 777s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 777s # The original create_connection function always returns all records. 777s family = allowed_gai_family() 777s 777s try: 777s host.encode("idna") 777s except UnicodeError: 777s raise LocationParseError(f"'{host}', label empty or too long") from None 777s 777s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 777s af, socktype, proto, canonname, sa = res 777s sock = None 777s try: 777s sock = socket.socket(af, socktype, proto) 777s 777s # If provided, set socket level options before connecting. 777s _set_socket_options(sock, socket_options) 777s 777s if timeout is not _DEFAULT_TIMEOUT: 777s sock.settimeout(timeout) 777s if source_address: 777s sock.bind(source_address) 777s > sock.connect(sa) 777s E ConnectionRefusedError: [Errno 111] Connection refused 777s 777s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 777s 777s The above exception was the direct cause of the following exception: 777s 777s self = 777s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 777s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 777s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 777s redirect = False, assert_same_host = False 777s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 777s release_conn = False, chunked = False, body_pos = None, preload_content = False 777s decode_content = False, response_kw = {} 777s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 777s destination_scheme = None, conn = None, release_this_conn = True 777s http_tunnel_required = False, err = None, clean_exit = False 777s 777s def urlopen( # type: ignore[override] 777s self, 777s method: str, 777s url: str, 777s body: _TYPE_BODY | None = None, 777s headers: typing.Mapping[str, str] | None = None, 777s retries: Retry | bool | int | None = None, 777s redirect: bool = True, 777s assert_same_host: bool = True, 777s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 777s pool_timeout: int | None = None, 777s release_conn: bool | None = None, 777s chunked: bool = False, 777s body_pos: _TYPE_BODY_POSITION | None = None, 777s preload_content: bool = True, 777s decode_content: bool = True, 777s **response_kw: typing.Any, 777s ) -> BaseHTTPResponse: 777s """ 777s Get a connection from the pool and perform an HTTP request. This is the 777s lowest level call for making a request, so you'll need to specify all 777s the raw details. 777s 777s .. note:: 777s 777s More commonly, it's appropriate to use a convenience method 777s such as :meth:`request`. 777s 777s .. note:: 777s 777s `release_conn` will only behave as expected if 777s `preload_content=False` because we want to make 777s `preload_content=False` the default behaviour someday soon without 777s breaking backwards compatibility. 777s 777s :param method: 777s HTTP request method (such as GET, POST, PUT, etc.) 777s 777s :param url: 777s The URL to perform the request on. 777s 777s :param body: 777s Data to send in the request body, either :class:`str`, :class:`bytes`, 777s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 777s 777s :param headers: 777s Dictionary of custom headers to send, such as User-Agent, 777s If-None-Match, etc. If None, pool headers are used. If provided, 777s these headers completely replace any pool-specific headers. 777s 777s :param retries: 777s Configure the number of retries to allow before raising a 777s :class:`~urllib3.exceptions.MaxRetryError` exception. 777s 777s Pass ``None`` to retry until you receive a response. Pass a 777s :class:`~urllib3.util.retry.Retry` object for fine-grained control 777s over different types of retries. 777s Pass an integer number to retry connection errors that many times, 777s but no other types of errors. Pass zero to never retry. 777s 777s If ``False``, then retries are disabled and any exception is raised 777s immediately. Also, instead of raising a MaxRetryError on redirects, 777s the redirect response will be returned. 777s 777s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 777s 777s :param redirect: 777s If True, automatically handle redirects (status codes 301, 302, 777s 303, 307, 308). Each redirect counts as a retry. Disabling retries 777s will disable redirect, too. 777s 777s :param assert_same_host: 777s If ``True``, will make sure that the host of the pool requests is 777s consistent else will raise HostChangedError. When ``False``, you can 777s use the pool on an HTTP proxy and request foreign hosts. 777s 777s :param timeout: 777s If specified, overrides the default timeout for this one 777s request. It may be a float (in seconds) or an instance of 777s :class:`urllib3.util.Timeout`. 777s 777s :param pool_timeout: 777s If set and the pool is set to block=True, then this method will 777s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 777s connection is available within the time period. 777s 777s :param bool preload_content: 777s If True, the response's body will be preloaded into memory. 777s 777s :param bool decode_content: 777s If True, will attempt to decode the body based on the 777s 'content-encoding' header. 777s 777s :param release_conn: 777s If False, then the urlopen call will not release the connection 777s back into the pool once a response is received (but will release if 777s you read the entire contents of the response such as when 777s `preload_content=True`). This is useful if you're not preloading 777s the response's content immediately. You will need to call 777s ``r.release_conn()`` on the response ``r`` to return the connection 777s back into the pool. If None, it takes the value of ``preload_content`` 777s which defaults to ``True``. 777s 777s :param bool chunked: 777s If True, urllib3 will send the body using chunked transfer 777s encoding. Otherwise, urllib3 will send the body using the standard 777s content-length form. Defaults to False. 777s 777s :param int body_pos: 777s Position to seek to in file-like body in the event of a retry or 777s redirect. Typically this won't need to be set because urllib3 will 777s auto-populate the value when needed. 777s """ 777s parsed_url = parse_url(url) 777s destination_scheme = parsed_url.scheme 777s 777s if headers is None: 777s headers = self.headers 777s 777s if not isinstance(retries, Retry): 777s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 777s 777s if release_conn is None: 777s release_conn = preload_content 777s 777s # Check host 777s if assert_same_host and not self.is_same_host(url): 777s raise HostChangedError(self, url, retries) 777s 777s # Ensure that the URL we're connecting to is properly encoded 777s if url.startswith("/"): 777s url = to_str(_encode_target(url)) 777s else: 777s url = to_str(parsed_url.url) 777s 777s conn = None 777s 777s # Track whether `conn` needs to be released before 777s # returning/raising/recursing. Update this variable if necessary, and 777s # leave `release_conn` constant throughout the function. That way, if 777s # the function recurses, the original value of `release_conn` will be 777s # passed down into the recursive call, and its value will be respected. 777s # 777s # See issue #651 [1] for details. 777s # 777s # [1] 777s release_this_conn = release_conn 777s 777s http_tunnel_required = connection_requires_http_tunnel( 777s self.proxy, self.proxy_config, destination_scheme 777s ) 777s 777s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 777s # have to copy the headers dict so we can safely change it without those 777s # changes being reflected in anyone else's copy. 777s if not http_tunnel_required: 777s headers = headers.copy() # type: ignore[attr-defined] 777s headers.update(self.proxy_headers) # type: ignore[union-attr] 777s 777s # Must keep the exception bound to a separate variable or else Python 3 777s # complains about UnboundLocalError. 777s err = None 777s 777s # Keep track of whether we cleanly exited the except block. This 777s # ensures we do proper cleanup in finally. 777s clean_exit = False 777s 777s # Rewind body position, if needed. Record current position 777s # for future rewinds in the event of a redirect/retry. 777s body_pos = set_file_position(body, body_pos) 777s 777s try: 777s # Request a connection from the queue. 777s timeout_obj = self._get_timeout(timeout) 777s conn = self._get_conn(timeout=pool_timeout) 777s 777s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 777s 777s # Is this a closed/new connection that requires CONNECT tunnelling? 777s if self.proxy is not None and http_tunnel_required and conn.is_closed: 777s try: 777s self._prepare_proxy(conn) 777s except (BaseSSLError, OSError, SocketTimeout) as e: 777s self._raise_timeout( 777s err=e, url=self.proxy.url, timeout_value=conn.timeout 777s ) 777s raise 777s 777s # If we're going to release the connection in ``finally:``, then 777s # the response doesn't need to know about the connection. Otherwise 777s # it will also try to release it and we'll have a double-release 777s # mess. 777s response_conn = conn if not release_conn else None 777s 777s # Make the request on the HTTPConnection object 777s > response = self._make_request( 777s conn, 777s method, 777s url, 777s timeout=timeout_obj, 777s body=body, 777s headers=headers, 777s chunked=chunked, 777s retries=retries, 777s response_conn=response_conn, 777s preload_content=preload_content, 777s decode_content=decode_content, 777s **response_kw, 777s ) 777s 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 777s raise new_e 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 777s self._validate_conn(conn) 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 777s conn.connect() 777s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 777s self.sock = sock = self._new_conn() 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s self = 777s 777s def _new_conn(self) -> socket.socket: 777s """Establish a socket connection and set nodelay settings on it. 777s 777s :return: New socket connection. 777s """ 777s try: 777s sock = connection.create_connection( 777s (self._dns_host, self.port), 777s self.timeout, 777s source_address=self.source_address, 777s socket_options=self.socket_options, 777s ) 777s except socket.gaierror as e: 777s raise NameResolutionError(self.host, self, e) from e 777s except SocketTimeout as e: 777s raise ConnectTimeoutError( 777s self, 777s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 777s ) from e 777s 777s except OSError as e: 777s > raise NewConnectionError( 777s self, f"Failed to establish a new connection: {e}" 777s ) from e 777s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 777s 777s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 777s 777s The above exception was the direct cause of the following exception: 777s 777s self = 777s request = , stream = False 777s timeout = Timeout(connect=None, read=None, total=None), verify = True 777s cert = None, proxies = OrderedDict() 777s 777s def send( 777s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 777s ): 777s """Sends PreparedRequest object. Returns Response object. 777s 777s :param request: The :class:`PreparedRequest ` being sent. 777s :param stream: (optional) Whether to stream the request content. 777s :param timeout: (optional) How long to wait for the server to send 777s data before giving up, as a float, or a :ref:`(connect timeout, 777s read timeout) ` tuple. 777s :type timeout: float or tuple or urllib3 Timeout object 777s :param verify: (optional) Either a boolean, in which case it controls whether 777s we verify the server's TLS certificate, or a string, in which case it 777s must be a path to a CA bundle to use 777s :param cert: (optional) Any user-provided SSL certificate to be trusted. 777s :param proxies: (optional) The proxies dictionary to apply to the request. 777s :rtype: requests.Response 777s """ 777s 777s try: 777s conn = self.get_connection_with_tls_context( 777s request, verify, proxies=proxies, cert=cert 777s ) 777s except LocationValueError as e: 777s raise InvalidURL(e, request=request) 777s 777s self.cert_verify(conn, request.url, verify, cert) 777s url = self.request_url(request, proxies) 777s self.add_headers( 777s request, 777s stream=stream, 777s timeout=timeout, 777s verify=verify, 777s cert=cert, 777s proxies=proxies, 777s ) 777s 777s chunked = not (request.body is None or "Content-Length" in request.headers) 777s 777s if isinstance(timeout, tuple): 777s try: 777s connect, read = timeout 777s timeout = TimeoutSauce(connect=connect, read=read) 777s except ValueError: 777s raise ValueError( 777s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 777s f"or a single float to set both timeouts to the same value." 777s ) 777s elif isinstance(timeout, TimeoutSauce): 777s pass 777s else: 777s timeout = TimeoutSauce(connect=timeout, read=timeout) 777s 777s try: 777s > resp = conn.urlopen( 777s method=request.method, 777s url=url, 777s body=request.body, 777s headers=request.headers, 777s redirect=False, 777s assert_same_host=False, 777s preload_content=False, 777s decode_content=False, 777s retries=self.max_retries, 777s timeout=timeout, 777s chunked=chunked, 777s ) 777s 777s /usr/lib/python3/dist-packages/requests/adapters.py:667: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 777s retries = retries.increment( 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 777s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 777s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 777s _pool = 777s _stacktrace = 777s 777s def increment( 777s self, 777s method: str | None = None, 777s url: str | None = None, 777s response: BaseHTTPResponse | None = None, 777s error: Exception | None = None, 777s _pool: ConnectionPool | None = None, 777s _stacktrace: TracebackType | None = None, 777s ) -> Retry: 777s """Return a new Retry object with incremented retry counters. 777s 777s :param response: A response object, or None, if the server did not 777s return a response. 777s :type response: :class:`~urllib3.response.BaseHTTPResponse` 777s :param Exception error: An error encountered during the request, or 777s None if the response was received successfully. 777s 777s :return: A new ``Retry`` object. 777s """ 777s if self.total is False and error: 777s # Disabled, indicate to re-raise the error. 777s raise reraise(type(error), error, _stacktrace) 777s 777s total = self.total 777s if total is not None: 777s total -= 1 777s 777s connect = self.connect 777s read = self.read 777s redirect = self.redirect 777s status_count = self.status 777s other = self.other 777s cause = "unknown" 777s status = None 777s redirect_location = None 777s 777s if error and self._is_connection_error(error): 777s # Connect retry? 777s if connect is False: 777s raise reraise(type(error), error, _stacktrace) 777s elif connect is not None: 777s connect -= 1 777s 777s elif error and self._is_read_error(error): 777s # Read retry? 777s if read is False or method is None or not self._is_method_retryable(method): 777s raise reraise(type(error), error, _stacktrace) 777s elif read is not None: 777s read -= 1 777s 777s elif error: 777s # Other retry? 777s if other is not None: 777s other -= 1 777s 777s elif response and response.get_redirect_location(): 777s # Redirect retry? 777s if redirect is not None: 777s redirect -= 1 777s cause = "too many redirects" 777s response_redirect_location = response.get_redirect_location() 777s if response_redirect_location: 777s redirect_location = response_redirect_location 777s status = response.status 777s 777s else: 777s # Incrementing because of a server error like a 500 in 777s # status_forcelist and the given method is in the allowed_methods 777s cause = ResponseError.GENERIC_ERROR 777s if response and response.status: 777s if status_count is not None: 777s status_count -= 1 777s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 777s status = response.status 777s 777s history = self.history + ( 777s RequestHistory(method, url, error, status, redirect_location), 777s ) 777s 777s new_retry = self.new( 777s total=total, 777s connect=connect, 777s read=read, 777s redirect=redirect, 777s status=status_count, 777s other=other, 777s history=history, 777s ) 777s 777s if new_retry.is_exhausted(): 777s reason = error or ResponseError(cause) 777s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 777s 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')) 777s 777s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 777s 777s During handling of the above exception, another exception occurred: 777s 777s def test_simple_repeated(): 777s > enc = tiktoken.get_encoding("gpt2") 777s 777s tests/test_encoding.py:32: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 777s enc = Encoding(**constructor()) 777s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 777s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 777s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 777s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 777s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 777s contents = read_file(blobpath) 777s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 777s resp = requests.get(blobpath) 777s /usr/lib/python3/dist-packages/requests/api.py:73: in get 777s return request("get", url, params=params, **kwargs) 777s /usr/lib/python3/dist-packages/requests/api.py:59: in request 777s return session.request(method=method, url=url, **kwargs) 777s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 777s resp = self.send(prep, **send_kwargs) 777s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 777s r = adapter.send(request, **kwargs) 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s self = 777s request = , stream = False 777s timeout = Timeout(connect=None, read=None, total=None), verify = True 777s cert = None, proxies = OrderedDict() 777s 777s def send( 777s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 777s ): 777s """Sends PreparedRequest object. Returns Response object. 777s 777s :param request: The :class:`PreparedRequest ` being sent. 777s :param stream: (optional) Whether to stream the request content. 777s :param timeout: (optional) How long to wait for the server to send 777s data before giving up, as a float, or a :ref:`(connect timeout, 777s read timeout) ` tuple. 777s :type timeout: float or tuple or urllib3 Timeout object 777s :param verify: (optional) Either a boolean, in which case it controls whether 777s we verify the server's TLS certificate, or a string, in which case it 777s must be a path to a CA bundle to use 777s :param cert: (optional) Any user-provided SSL certificate to be trusted. 777s :param proxies: (optional) The proxies dictionary to apply to the request. 777s :rtype: requests.Response 777s """ 777s 777s try: 777s conn = self.get_connection_with_tls_context( 777s request, verify, proxies=proxies, cert=cert 777s ) 777s except LocationValueError as e: 777s raise InvalidURL(e, request=request) 777s 777s self.cert_verify(conn, request.url, verify, cert) 777s url = self.request_url(request, proxies) 777s self.add_headers( 777s request, 777s stream=stream, 777s timeout=timeout, 777s verify=verify, 777s cert=cert, 777s proxies=proxies, 777s ) 777s 777s chunked = not (request.body is None or "Content-Length" in request.headers) 777s 777s if isinstance(timeout, tuple): 777s try: 777s connect, read = timeout 777s timeout = TimeoutSauce(connect=connect, read=read) 777s except ValueError: 777s raise ValueError( 777s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 777s f"or a single float to set both timeouts to the same value." 777s ) 777s elif isinstance(timeout, TimeoutSauce): 777s pass 777s else: 777s timeout = TimeoutSauce(connect=timeout, read=timeout) 777s 777s try: 777s resp = conn.urlopen( 777s method=request.method, 777s url=url, 777s body=request.body, 777s headers=request.headers, 777s redirect=False, 777s assert_same_host=False, 777s preload_content=False, 777s decode_content=False, 777s retries=self.max_retries, 777s timeout=timeout, 777s chunked=chunked, 777s ) 777s 777s except (ProtocolError, OSError) as err: 777s raise ConnectionError(err, request=request) 777s 777s except MaxRetryError as e: 777s if isinstance(e.reason, ConnectTimeoutError): 777s # TODO: Remove this in 3.0.0: see #2811 777s if not isinstance(e.reason, NewConnectionError): 777s raise ConnectTimeout(e, request=request) 777s 777s if isinstance(e.reason, ResponseError): 777s raise RetryError(e, request=request) 777s 777s if isinstance(e.reason, _ProxyError): 777s raise ProxyError(e, request=request) 777s 777s if isinstance(e.reason, _SSLError): 777s # This branch is for urllib3 v1.22 and later. 777s raise SSLError(e, request=request) 777s 777s > raise ConnectionError(e, request=request) 777s 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')) 777s 777s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 777s ______________________________ test_simple_regex _______________________________ 777s 777s self = 777s 777s def _new_conn(self) -> socket.socket: 777s """Establish a socket connection and set nodelay settings on it. 777s 777s :return: New socket connection. 777s """ 777s try: 777s > sock = connection.create_connection( 777s (self._dns_host, self.port), 777s self.timeout, 777s source_address=self.source_address, 777s socket_options=self.socket_options, 777s ) 777s 777s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 777s raise err 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 777s source_address = None, socket_options = [(6, 1, 1)] 777s 777s def create_connection( 777s address: tuple[str, int], 777s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 777s source_address: tuple[str, int] | None = None, 777s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 777s ) -> socket.socket: 777s """Connect to *address* and return the socket object. 777s 777s Convenience function. Connect to *address* (a 2-tuple ``(host, 777s port)``) and return the socket object. Passing the optional 777s *timeout* parameter will set the timeout on the socket instance 777s before attempting to connect. If no *timeout* is supplied, the 777s global default timeout setting returned by :func:`socket.getdefaulttimeout` 777s is used. If *source_address* is set it must be a tuple of (host, port) 777s for the socket to bind as a source address before making the connection. 777s An host of '' or port 0 tells the OS to use the default. 777s """ 777s 777s host, port = address 777s if host.startswith("["): 777s host = host.strip("[]") 777s err = None 777s 777s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 777s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 777s # The original create_connection function always returns all records. 777s family = allowed_gai_family() 777s 777s try: 777s host.encode("idna") 777s except UnicodeError: 777s raise LocationParseError(f"'{host}', label empty or too long") from None 777s 777s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 777s af, socktype, proto, canonname, sa = res 777s sock = None 777s try: 777s sock = socket.socket(af, socktype, proto) 777s 777s # If provided, set socket level options before connecting. 777s _set_socket_options(sock, socket_options) 777s 777s if timeout is not _DEFAULT_TIMEOUT: 777s sock.settimeout(timeout) 777s if source_address: 777s sock.bind(source_address) 777s > sock.connect(sa) 777s E ConnectionRefusedError: [Errno 111] Connection refused 777s 777s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 777s 777s The above exception was the direct cause of the following exception: 777s 777s self = 777s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 777s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 777s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 777s redirect = False, assert_same_host = False 777s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 777s release_conn = False, chunked = False, body_pos = None, preload_content = False 777s decode_content = False, response_kw = {} 777s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 777s destination_scheme = None, conn = None, release_this_conn = True 777s http_tunnel_required = False, err = None, clean_exit = False 777s 777s def urlopen( # type: ignore[override] 777s self, 777s method: str, 777s url: str, 777s body: _TYPE_BODY | None = None, 777s headers: typing.Mapping[str, str] | None = None, 777s retries: Retry | bool | int | None = None, 777s redirect: bool = True, 777s assert_same_host: bool = True, 777s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 777s pool_timeout: int | None = None, 777s release_conn: bool | None = None, 777s chunked: bool = False, 777s body_pos: _TYPE_BODY_POSITION | None = None, 777s preload_content: bool = True, 777s decode_content: bool = True, 777s **response_kw: typing.Any, 777s ) -> BaseHTTPResponse: 777s """ 777s Get a connection from the pool and perform an HTTP request. This is the 777s lowest level call for making a request, so you'll need to specify all 777s the raw details. 777s 777s .. note:: 777s 777s More commonly, it's appropriate to use a convenience method 777s such as :meth:`request`. 777s 777s .. note:: 777s 777s `release_conn` will only behave as expected if 777s `preload_content=False` because we want to make 777s `preload_content=False` the default behaviour someday soon without 777s breaking backwards compatibility. 777s 777s :param method: 777s HTTP request method (such as GET, POST, PUT, etc.) 777s 777s :param url: 777s The URL to perform the request on. 777s 777s :param body: 777s Data to send in the request body, either :class:`str`, :class:`bytes`, 777s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 777s 777s :param headers: 777s Dictionary of custom headers to send, such as User-Agent, 777s If-None-Match, etc. If None, pool headers are used. If provided, 777s these headers completely replace any pool-specific headers. 777s 777s :param retries: 777s Configure the number of retries to allow before raising a 777s :class:`~urllib3.exceptions.MaxRetryError` exception. 777s 777s Pass ``None`` to retry until you receive a response. Pass a 777s :class:`~urllib3.util.retry.Retry` object for fine-grained control 777s over different types of retries. 777s Pass an integer number to retry connection errors that many times, 777s but no other types of errors. Pass zero to never retry. 777s 777s If ``False``, then retries are disabled and any exception is raised 777s immediately. Also, instead of raising a MaxRetryError on redirects, 777s the redirect response will be returned. 777s 777s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 777s 777s :param redirect: 777s If True, automatically handle redirects (status codes 301, 302, 777s 303, 307, 308). Each redirect counts as a retry. Disabling retries 777s will disable redirect, too. 777s 777s :param assert_same_host: 777s If ``True``, will make sure that the host of the pool requests is 777s consistent else will raise HostChangedError. When ``False``, you can 777s use the pool on an HTTP proxy and request foreign hosts. 777s 777s :param timeout: 777s If specified, overrides the default timeout for this one 777s request. It may be a float (in seconds) or an instance of 777s :class:`urllib3.util.Timeout`. 777s 777s :param pool_timeout: 777s If set and the pool is set to block=True, then this method will 777s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 777s connection is available within the time period. 777s 777s :param bool preload_content: 777s If True, the response's body will be preloaded into memory. 777s 777s :param bool decode_content: 777s If True, will attempt to decode the body based on the 777s 'content-encoding' header. 777s 777s :param release_conn: 777s If False, then the urlopen call will not release the connection 777s back into the pool once a response is received (but will release if 777s you read the entire contents of the response such as when 777s `preload_content=True`). This is useful if you're not preloading 777s the response's content immediately. You will need to call 777s ``r.release_conn()`` on the response ``r`` to return the connection 777s back into the pool. If None, it takes the value of ``preload_content`` 777s which defaults to ``True``. 777s 777s :param bool chunked: 777s If True, urllib3 will send the body using chunked transfer 777s encoding. Otherwise, urllib3 will send the body using the standard 777s content-length form. Defaults to False. 777s 777s :param int body_pos: 777s Position to seek to in file-like body in the event of a retry or 777s redirect. Typically this won't need to be set because urllib3 will 777s auto-populate the value when needed. 777s """ 777s parsed_url = parse_url(url) 777s destination_scheme = parsed_url.scheme 777s 777s if headers is None: 777s headers = self.headers 777s 777s if not isinstance(retries, Retry): 777s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 777s 777s if release_conn is None: 777s release_conn = preload_content 777s 777s # Check host 777s if assert_same_host and not self.is_same_host(url): 777s raise HostChangedError(self, url, retries) 777s 777s # Ensure that the URL we're connecting to is properly encoded 777s if url.startswith("/"): 777s url = to_str(_encode_target(url)) 777s else: 777s url = to_str(parsed_url.url) 777s 777s conn = None 777s 777s # Track whether `conn` needs to be released before 777s # returning/raising/recursing. Update this variable if necessary, and 777s # leave `release_conn` constant throughout the function. That way, if 777s # the function recurses, the original value of `release_conn` will be 777s # passed down into the recursive call, and its value will be respected. 777s # 777s # See issue #651 [1] for details. 777s # 777s # [1] 777s release_this_conn = release_conn 777s 777s http_tunnel_required = connection_requires_http_tunnel( 777s self.proxy, self.proxy_config, destination_scheme 777s ) 777s 777s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 777s # have to copy the headers dict so we can safely change it without those 777s # changes being reflected in anyone else's copy. 777s if not http_tunnel_required: 777s headers = headers.copy() # type: ignore[attr-defined] 777s headers.update(self.proxy_headers) # type: ignore[union-attr] 777s 777s # Must keep the exception bound to a separate variable or else Python 3 777s # complains about UnboundLocalError. 777s err = None 777s 777s # Keep track of whether we cleanly exited the except block. This 777s # ensures we do proper cleanup in finally. 777s clean_exit = False 777s 777s # Rewind body position, if needed. Record current position 777s # for future rewinds in the event of a redirect/retry. 777s body_pos = set_file_position(body, body_pos) 777s 777s try: 777s # Request a connection from the queue. 777s timeout_obj = self._get_timeout(timeout) 777s conn = self._get_conn(timeout=pool_timeout) 777s 777s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 777s 777s # Is this a closed/new connection that requires CONNECT tunnelling? 777s if self.proxy is not None and http_tunnel_required and conn.is_closed: 777s try: 777s self._prepare_proxy(conn) 777s except (BaseSSLError, OSError, SocketTimeout) as e: 777s self._raise_timeout( 777s err=e, url=self.proxy.url, timeout_value=conn.timeout 777s ) 777s raise 777s 777s # If we're going to release the connection in ``finally:``, then 777s # the response doesn't need to know about the connection. Otherwise 777s # it will also try to release it and we'll have a double-release 777s # mess. 777s response_conn = conn if not release_conn else None 777s 777s # Make the request on the HTTPConnection object 777s > response = self._make_request( 777s conn, 777s method, 777s url, 777s timeout=timeout_obj, 777s body=body, 777s headers=headers, 777s chunked=chunked, 777s retries=retries, 777s response_conn=response_conn, 777s preload_content=preload_content, 777s decode_content=decode_content, 777s **response_kw, 777s ) 777s 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 777s raise new_e 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 777s self._validate_conn(conn) 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 777s conn.connect() 777s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 777s self.sock = sock = self._new_conn() 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s self = 777s 777s def _new_conn(self) -> socket.socket: 777s """Establish a socket connection and set nodelay settings on it. 777s 777s :return: New socket connection. 777s """ 777s try: 777s sock = connection.create_connection( 777s (self._dns_host, self.port), 777s self.timeout, 777s source_address=self.source_address, 777s socket_options=self.socket_options, 777s ) 777s except socket.gaierror as e: 777s raise NameResolutionError(self.host, self, e) from e 777s except SocketTimeout as e: 777s raise ConnectTimeoutError( 777s self, 777s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 777s ) from e 777s 777s except OSError as e: 777s > raise NewConnectionError( 777s self, f"Failed to establish a new connection: {e}" 777s ) from e 777s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 777s 777s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 777s 777s The above exception was the direct cause of the following exception: 777s 777s self = 777s request = , stream = False 777s timeout = Timeout(connect=None, read=None, total=None), verify = True 777s cert = None, proxies = OrderedDict() 777s 777s def send( 777s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 777s ): 777s """Sends PreparedRequest object. Returns Response object. 777s 777s :param request: The :class:`PreparedRequest ` being sent. 777s :param stream: (optional) Whether to stream the request content. 777s :param timeout: (optional) How long to wait for the server to send 777s data before giving up, as a float, or a :ref:`(connect timeout, 777s read timeout) ` tuple. 777s :type timeout: float or tuple or urllib3 Timeout object 777s :param verify: (optional) Either a boolean, in which case it controls whether 777s we verify the server's TLS certificate, or a string, in which case it 777s must be a path to a CA bundle to use 777s :param cert: (optional) Any user-provided SSL certificate to be trusted. 777s :param proxies: (optional) The proxies dictionary to apply to the request. 777s :rtype: requests.Response 777s """ 777s 777s try: 777s conn = self.get_connection_with_tls_context( 777s request, verify, proxies=proxies, cert=cert 777s ) 777s except LocationValueError as e: 777s raise InvalidURL(e, request=request) 777s 777s self.cert_verify(conn, request.url, verify, cert) 777s url = self.request_url(request, proxies) 777s self.add_headers( 777s request, 777s stream=stream, 777s timeout=timeout, 777s verify=verify, 777s cert=cert, 777s proxies=proxies, 777s ) 777s 777s chunked = not (request.body is None or "Content-Length" in request.headers) 777s 777s if isinstance(timeout, tuple): 777s try: 777s connect, read = timeout 777s timeout = TimeoutSauce(connect=connect, read=read) 777s except ValueError: 777s raise ValueError( 777s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 777s f"or a single float to set both timeouts to the same value." 777s ) 777s elif isinstance(timeout, TimeoutSauce): 777s pass 777s else: 777s timeout = TimeoutSauce(connect=timeout, read=timeout) 777s 777s try: 777s > resp = conn.urlopen( 777s method=request.method, 777s url=url, 777s body=request.body, 777s headers=request.headers, 777s redirect=False, 777s assert_same_host=False, 777s preload_content=False, 777s decode_content=False, 777s retries=self.max_retries, 777s timeout=timeout, 777s chunked=chunked, 777s ) 777s 777s /usr/lib/python3/dist-packages/requests/adapters.py:667: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 777s retries = retries.increment( 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 777s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 777s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 777s _pool = 777s _stacktrace = 777s 777s def increment( 777s self, 777s method: str | None = None, 777s url: str | None = None, 777s response: BaseHTTPResponse | None = None, 777s error: Exception | None = None, 777s _pool: ConnectionPool | None = None, 777s _stacktrace: TracebackType | None = None, 777s ) -> Retry: 777s """Return a new Retry object with incremented retry counters. 777s 777s :param response: A response object, or None, if the server did not 777s return a response. 777s :type response: :class:`~urllib3.response.BaseHTTPResponse` 777s :param Exception error: An error encountered during the request, or 777s None if the response was received successfully. 777s 777s :return: A new ``Retry`` object. 777s """ 777s if self.total is False and error: 777s # Disabled, indicate to re-raise the error. 777s raise reraise(type(error), error, _stacktrace) 777s 777s total = self.total 777s if total is not None: 777s total -= 1 777s 777s connect = self.connect 777s read = self.read 777s redirect = self.redirect 777s status_count = self.status 777s other = self.other 777s cause = "unknown" 777s status = None 777s redirect_location = None 777s 777s if error and self._is_connection_error(error): 777s # Connect retry? 777s if connect is False: 777s raise reraise(type(error), error, _stacktrace) 777s elif connect is not None: 777s connect -= 1 777s 777s elif error and self._is_read_error(error): 777s # Read retry? 777s if read is False or method is None or not self._is_method_retryable(method): 777s raise reraise(type(error), error, _stacktrace) 777s elif read is not None: 777s read -= 1 777s 777s elif error: 777s # Other retry? 777s if other is not None: 777s other -= 1 777s 777s elif response and response.get_redirect_location(): 777s # Redirect retry? 777s if redirect is not None: 777s redirect -= 1 777s cause = "too many redirects" 777s response_redirect_location = response.get_redirect_location() 777s if response_redirect_location: 777s redirect_location = response_redirect_location 777s status = response.status 777s 777s else: 777s # Incrementing because of a server error like a 500 in 777s # status_forcelist and the given method is in the allowed_methods 777s cause = ResponseError.GENERIC_ERROR 777s if response and response.status: 777s if status_count is not None: 777s status_count -= 1 777s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 777s status = response.status 777s 777s history = self.history + ( 777s RequestHistory(method, url, error, status, redirect_location), 777s ) 777s 777s new_retry = self.new( 777s total=total, 777s connect=connect, 777s read=read, 777s redirect=redirect, 777s status=status_count, 777s other=other, 777s history=history, 777s ) 777s 777s if new_retry.is_exhausted(): 777s reason = error or ResponseError(cause) 777s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 777s 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')) 777s 777s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 777s 777s During handling of the above exception, another exception occurred: 777s 777s def test_simple_regex(): 777s > enc = tiktoken.get_encoding("cl100k_base") 777s 777s tests/test_encoding.py:53: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 777s enc = Encoding(**constructor()) 777s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 777s mergeable_ranks = load_tiktoken_bpe( 777s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 777s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 777s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 777s contents = read_file(blobpath) 777s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 777s resp = requests.get(blobpath) 777s /usr/lib/python3/dist-packages/requests/api.py:73: in get 777s return request("get", url, params=params, **kwargs) 777s /usr/lib/python3/dist-packages/requests/api.py:59: in request 777s return session.request(method=method, url=url, **kwargs) 777s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 777s resp = self.send(prep, **send_kwargs) 777s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 777s r = adapter.send(request, **kwargs) 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s self = 777s request = , stream = False 777s timeout = Timeout(connect=None, read=None, total=None), verify = True 777s cert = None, proxies = OrderedDict() 777s 777s def send( 777s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 777s ): 777s """Sends PreparedRequest object. Returns Response object. 777s 777s :param request: The :class:`PreparedRequest ` being sent. 777s :param stream: (optional) Whether to stream the request content. 777s :param timeout: (optional) How long to wait for the server to send 777s data before giving up, as a float, or a :ref:`(connect timeout, 777s read timeout) ` tuple. 777s :type timeout: float or tuple or urllib3 Timeout object 777s :param verify: (optional) Either a boolean, in which case it controls whether 777s we verify the server's TLS certificate, or a string, in which case it 777s must be a path to a CA bundle to use 777s :param cert: (optional) Any user-provided SSL certificate to be trusted. 777s :param proxies: (optional) The proxies dictionary to apply to the request. 777s :rtype: requests.Response 777s """ 777s 777s try: 777s conn = self.get_connection_with_tls_context( 777s request, verify, proxies=proxies, cert=cert 777s ) 777s except LocationValueError as e: 777s raise InvalidURL(e, request=request) 777s 777s self.cert_verify(conn, request.url, verify, cert) 777s url = self.request_url(request, proxies) 777s self.add_headers( 777s request, 777s stream=stream, 777s timeout=timeout, 777s verify=verify, 777s cert=cert, 777s proxies=proxies, 777s ) 777s 777s chunked = not (request.body is None or "Content-Length" in request.headers) 777s 777s if isinstance(timeout, tuple): 777s try: 777s connect, read = timeout 777s timeout = TimeoutSauce(connect=connect, read=read) 777s except ValueError: 777s raise ValueError( 777s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 777s f"or a single float to set both timeouts to the same value." 777s ) 777s elif isinstance(timeout, TimeoutSauce): 777s pass 777s else: 777s timeout = TimeoutSauce(connect=timeout, read=timeout) 777s 777s try: 777s resp = conn.urlopen( 777s method=request.method, 777s url=url, 777s body=request.body, 777s headers=request.headers, 777s redirect=False, 777s assert_same_host=False, 777s preload_content=False, 777s decode_content=False, 777s retries=self.max_retries, 777s timeout=timeout, 777s chunked=chunked, 777s ) 777s 777s except (ProtocolError, OSError) as err: 777s raise ConnectionError(err, request=request) 777s 777s except MaxRetryError as e: 777s if isinstance(e.reason, ConnectTimeoutError): 777s # TODO: Remove this in 3.0.0: see #2811 777s if not isinstance(e.reason, NewConnectionError): 777s raise ConnectTimeout(e, request=request) 777s 777s if isinstance(e.reason, ResponseError): 777s raise RetryError(e, request=request) 777s 777s if isinstance(e.reason, _ProxyError): 777s raise ProxyError(e, request=request) 777s 777s if isinstance(e.reason, _SSLError): 777s # This branch is for urllib3 v1.22 and later. 777s raise SSLError(e, request=request) 777s 777s > raise ConnectionError(e, request=request) 777s 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')) 777s 777s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 777s ______________________________ test_basic_encode _______________________________ 777s 777s self = 777s 777s def _new_conn(self) -> socket.socket: 777s """Establish a socket connection and set nodelay settings on it. 777s 777s :return: New socket connection. 777s """ 777s try: 777s > sock = connection.create_connection( 777s (self._dns_host, self.port), 777s self.timeout, 777s source_address=self.source_address, 777s socket_options=self.socket_options, 777s ) 777s 777s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 777s raise err 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 777s source_address = None, socket_options = [(6, 1, 1)] 777s 777s def create_connection( 777s address: tuple[str, int], 777s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 777s source_address: tuple[str, int] | None = None, 777s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 777s ) -> socket.socket: 777s """Connect to *address* and return the socket object. 777s 777s Convenience function. Connect to *address* (a 2-tuple ``(host, 777s port)``) and return the socket object. Passing the optional 777s *timeout* parameter will set the timeout on the socket instance 777s before attempting to connect. If no *timeout* is supplied, the 777s global default timeout setting returned by :func:`socket.getdefaulttimeout` 777s is used. If *source_address* is set it must be a tuple of (host, port) 777s for the socket to bind as a source address before making the connection. 777s An host of '' or port 0 tells the OS to use the default. 777s """ 777s 777s host, port = address 777s if host.startswith("["): 777s host = host.strip("[]") 777s err = None 777s 777s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 777s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 777s # The original create_connection function always returns all records. 777s family = allowed_gai_family() 777s 777s try: 777s host.encode("idna") 777s except UnicodeError: 777s raise LocationParseError(f"'{host}', label empty or too long") from None 777s 777s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 777s af, socktype, proto, canonname, sa = res 777s sock = None 777s try: 777s sock = socket.socket(af, socktype, proto) 777s 777s # If provided, set socket level options before connecting. 777s _set_socket_options(sock, socket_options) 777s 777s if timeout is not _DEFAULT_TIMEOUT: 777s sock.settimeout(timeout) 777s if source_address: 777s sock.bind(source_address) 777s > sock.connect(sa) 777s E ConnectionRefusedError: [Errno 111] Connection refused 777s 777s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 777s 777s The above exception was the direct cause of the following exception: 777s 777s self = 777s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 777s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 777s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 777s redirect = False, assert_same_host = False 777s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 777s release_conn = False, chunked = False, body_pos = None, preload_content = False 777s decode_content = False, response_kw = {} 777s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 777s destination_scheme = None, conn = None, release_this_conn = True 777s http_tunnel_required = False, err = None, clean_exit = False 777s 777s def urlopen( # type: ignore[override] 777s self, 777s method: str, 777s url: str, 777s body: _TYPE_BODY | None = None, 777s headers: typing.Mapping[str, str] | None = None, 777s retries: Retry | bool | int | None = None, 777s redirect: bool = True, 777s assert_same_host: bool = True, 777s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 777s pool_timeout: int | None = None, 777s release_conn: bool | None = None, 777s chunked: bool = False, 777s body_pos: _TYPE_BODY_POSITION | None = None, 777s preload_content: bool = True, 777s decode_content: bool = True, 777s **response_kw: typing.Any, 777s ) -> BaseHTTPResponse: 777s """ 777s Get a connection from the pool and perform an HTTP request. This is the 777s lowest level call for making a request, so you'll need to specify all 777s the raw details. 777s 777s .. note:: 777s 777s More commonly, it's appropriate to use a convenience method 777s such as :meth:`request`. 777s 777s .. note:: 777s 777s `release_conn` will only behave as expected if 777s `preload_content=False` because we want to make 777s `preload_content=False` the default behaviour someday soon without 777s breaking backwards compatibility. 777s 777s :param method: 777s HTTP request method (such as GET, POST, PUT, etc.) 777s 777s :param url: 777s The URL to perform the request on. 777s 777s :param body: 777s Data to send in the request body, either :class:`str`, :class:`bytes`, 777s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 777s 777s :param headers: 777s Dictionary of custom headers to send, such as User-Agent, 777s If-None-Match, etc. If None, pool headers are used. If provided, 777s these headers completely replace any pool-specific headers. 777s 777s :param retries: 777s Configure the number of retries to allow before raising a 777s :class:`~urllib3.exceptions.MaxRetryError` exception. 777s 777s Pass ``None`` to retry until you receive a response. Pass a 777s :class:`~urllib3.util.retry.Retry` object for fine-grained control 777s over different types of retries. 777s Pass an integer number to retry connection errors that many times, 777s but no other types of errors. Pass zero to never retry. 777s 777s If ``False``, then retries are disabled and any exception is raised 777s immediately. Also, instead of raising a MaxRetryError on redirects, 777s the redirect response will be returned. 777s 777s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 777s 777s :param redirect: 777s If True, automatically handle redirects (status codes 301, 302, 777s 303, 307, 308). Each redirect counts as a retry. Disabling retries 777s will disable redirect, too. 777s 777s :param assert_same_host: 777s If ``True``, will make sure that the host of the pool requests is 777s consistent else will raise HostChangedError. When ``False``, you can 777s use the pool on an HTTP proxy and request foreign hosts. 777s 777s :param timeout: 777s If specified, overrides the default timeout for this one 777s request. It may be a float (in seconds) or an instance of 777s :class:`urllib3.util.Timeout`. 777s 777s :param pool_timeout: 777s If set and the pool is set to block=True, then this method will 777s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 777s connection is available within the time period. 777s 777s :param bool preload_content: 777s If True, the response's body will be preloaded into memory. 777s 777s :param bool decode_content: 777s If True, will attempt to decode the body based on the 777s 'content-encoding' header. 777s 777s :param release_conn: 777s If False, then the urlopen call will not release the connection 777s back into the pool once a response is received (but will release if 777s you read the entire contents of the response such as when 777s `preload_content=True`). This is useful if you're not preloading 777s the response's content immediately. You will need to call 777s ``r.release_conn()`` on the response ``r`` to return the connection 777s back into the pool. If None, it takes the value of ``preload_content`` 777s which defaults to ``True``. 777s 777s :param bool chunked: 777s If True, urllib3 will send the body using chunked transfer 777s encoding. Otherwise, urllib3 will send the body using the standard 777s content-length form. Defaults to False. 777s 777s :param int body_pos: 777s Position to seek to in file-like body in the event of a retry or 777s redirect. Typically this won't need to be set because urllib3 will 777s auto-populate the value when needed. 777s """ 777s parsed_url = parse_url(url) 777s destination_scheme = parsed_url.scheme 777s 777s if headers is None: 777s headers = self.headers 777s 777s if not isinstance(retries, Retry): 777s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 777s 777s if release_conn is None: 777s release_conn = preload_content 777s 777s # Check host 777s if assert_same_host and not self.is_same_host(url): 777s raise HostChangedError(self, url, retries) 777s 777s # Ensure that the URL we're connecting to is properly encoded 777s if url.startswith("/"): 777s url = to_str(_encode_target(url)) 777s else: 777s url = to_str(parsed_url.url) 777s 777s conn = None 777s 777s # Track whether `conn` needs to be released before 777s # returning/raising/recursing. Update this variable if necessary, and 777s # leave `release_conn` constant throughout the function. That way, if 777s # the function recurses, the original value of `release_conn` will be 777s # passed down into the recursive call, and its value will be respected. 777s # 777s # See issue #651 [1] for details. 777s # 777s # [1] 777s release_this_conn = release_conn 777s 777s http_tunnel_required = connection_requires_http_tunnel( 777s self.proxy, self.proxy_config, destination_scheme 777s ) 777s 777s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 777s # have to copy the headers dict so we can safely change it without those 777s # changes being reflected in anyone else's copy. 777s if not http_tunnel_required: 777s headers = headers.copy() # type: ignore[attr-defined] 777s headers.update(self.proxy_headers) # type: ignore[union-attr] 777s 777s # Must keep the exception bound to a separate variable or else Python 3 777s # complains about UnboundLocalError. 777s err = None 777s 777s # Keep track of whether we cleanly exited the except block. This 777s # ensures we do proper cleanup in finally. 777s clean_exit = False 777s 777s # Rewind body position, if needed. Record current position 777s # for future rewinds in the event of a redirect/retry. 777s body_pos = set_file_position(body, body_pos) 777s 777s try: 777s # Request a connection from the queue. 777s timeout_obj = self._get_timeout(timeout) 777s conn = self._get_conn(timeout=pool_timeout) 777s 777s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 777s 777s # Is this a closed/new connection that requires CONNECT tunnelling? 777s if self.proxy is not None and http_tunnel_required and conn.is_closed: 777s try: 777s self._prepare_proxy(conn) 777s except (BaseSSLError, OSError, SocketTimeout) as e: 777s self._raise_timeout( 777s err=e, url=self.proxy.url, timeout_value=conn.timeout 777s ) 777s raise 777s 777s # If we're going to release the connection in ``finally:``, then 777s # the response doesn't need to know about the connection. Otherwise 777s # it will also try to release it and we'll have a double-release 777s # mess. 777s response_conn = conn if not release_conn else None 777s 777s # Make the request on the HTTPConnection object 777s > response = self._make_request( 777s conn, 777s method, 777s url, 777s timeout=timeout_obj, 777s body=body, 777s headers=headers, 777s chunked=chunked, 777s retries=retries, 777s response_conn=response_conn, 777s preload_content=preload_content, 777s decode_content=decode_content, 777s **response_kw, 777s ) 777s 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 777s raise new_e 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 777s self._validate_conn(conn) 777s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 777s conn.connect() 777s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 777s self.sock = sock = self._new_conn() 777s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 777s 777s self = 777s 777s def _new_conn(self) -> socket.socket: 777s """Establish a socket connection and set nodelay settings on it. 777s 777s :return: New socket connection. 777s """ 777s try: 777s sock = connection.create_connection( 777s (self._dns_host, self.port), 777s self.timeout, 777s source_address=self.source_address, 777s socket_options=self.socket_options, 777s ) 777s except socket.gaierror as e: 777s raise NameResolutionError(self.host, self, e) from e 777s except SocketTimeout as e: 777s raise ConnectTimeoutError( 777s self, 777s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 777s ) from e 777s 777s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s def test_basic_encode(): 778s > enc = tiktoken.get_encoding("r50k_base") 778s 778s tests/test_encoding.py:62: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ______________________________ test_encode_empty _______________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s def test_encode_empty(): 778s > enc = tiktoken.get_encoding("r50k_base") 778s 778s tests/test_encoding.py:74: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ______________________________ test_encode_bytes _______________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s def test_encode_bytes(): 778s > enc = tiktoken.get_encoding("cl100k_base") 778s 778s tests/test_encoding.py:79: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s _________________________ test_encode_surrogate_pairs __________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s def test_encode_surrogate_pairs(): 778s > enc = tiktoken.get_encoding("cl100k_base") 778s 778s tests/test_encoding.py:84: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s _________________ test_catastrophically_repetitive[r50k_base] __________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'r50k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s def test_catastrophically_repetitive(make_enc: Callable[[], tiktoken.Encoding]): 778s > enc = make_enc() 778s 778s tests/test_encoding.py:96: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ________________ test_catastrophically_repetitive[cl100k_base] _________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'cl100k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s def test_catastrophically_repetitive(make_enc: Callable[[], tiktoken.Encoding]): 778s > enc = make_enc() 778s 778s tests/test_encoding.py:96: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s _______________________ test_basic_roundtrip[r50k_base] ________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'r50k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s def test_basic_roundtrip(make_enc): 778s > enc = make_enc() 778s 778s tests/test_encoding.py:115: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ______________________ test_basic_roundtrip[cl100k_base] _______________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'cl100k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s def test_basic_roundtrip(make_enc): 778s > enc = make_enc() 778s 778s tests/test_encoding.py:115: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ________________________ test_hyp_roundtrip[r50k_base] _________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'r50k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s > @hypothesis.given(text=st.text()) 778s 778s tests/test_encoding.py:131: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s tests/test_encoding.py:134: in test_hyp_roundtrip 778s enc = make_enc() 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s E Falsifying example: test_hyp_roundtrip( 778s E make_enc=functools.partial(get_encoding, 'r50k_base'), 778s E text='', 778s E ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s _______________________ test_hyp_roundtrip[cl100k_base] ________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'cl100k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s > @hypothesis.given(text=st.text()) 778s 778s tests/test_encoding.py:131: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s tests/test_encoding.py:134: in test_hyp_roundtrip 778s enc = make_enc() 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s E Falsifying example: test_hyp_roundtrip( 778s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 778s E text='', 778s E ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ____________________ test_single_token_roundtrip[r50k_base] ____________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'r50k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s def test_single_token_roundtrip(make_enc: Callable[[], tiktoken.Encoding]): 778s > enc = make_enc() 778s 778s tests/test_encoding.py:141: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ___________________ test_single_token_roundtrip[cl100k_base] ___________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'cl100k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s def test_single_token_roundtrip(make_enc: Callable[[], tiktoken.Encoding]): 778s > enc = make_enc() 778s 778s tests/test_encoding.py:141: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ______________________________ test_special_token ______________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s def test_special_token(): 778s > enc = tiktoken.get_encoding("cl100k_base") 778s 778s tests/test_encoding.py:157: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s _____________________ test_hyp_special_ordinary[r50k_base] _____________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'r50k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s > @hypothesis.given(text=st.text()) 778s 778s tests/test_encoding.py:208: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s tests/test_encoding.py:211: in test_hyp_special_ordinary 778s enc = make_enc() 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s E Falsifying example: test_hyp_special_ordinary( 778s E make_enc=functools.partial(get_encoding, 'r50k_base'), 778s E text='', 778s E ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ____________________ test_hyp_special_ordinary[cl100k_base] ____________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'cl100k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s > @hypothesis.given(text=st.text()) 778s 778s tests/test_encoding.py:208: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s tests/test_encoding.py:211: in test_hyp_special_ordinary 778s enc = make_enc() 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s E Falsifying example: test_hyp_special_ordinary( 778s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 778s E text='', 778s E ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s _________________________ test_batch_encode[r50k_base] _________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or methoE: pybuild pybuild:389: test: plugin pyproject failed with: exit code=1: cd /tmp/autopkgtest.rTBs3P/autopkgtest_tmp/build; python3.12 -m pytest tests 778s pybuild-autopkgtest: error: pybuild --autopkgtest --test-pytest -i python{version} -p "3.13 3.12" returned exit code 13 778s make: *** [/tmp/McJdL2dsrF/run:4: pybuild-autopkgtest] Error 25 778s pybuild-autopkgtest: error: /tmp/McJdL2dsrF/run pybuild-autopkgtest returned exit code 2 778s d is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'r50k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s def test_batch_encode(make_enc: Callable[[], tiktoken.Encoding]): 778s > enc = make_enc() 778s 778s tests/test_encoding.py:222: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ________________________ test_batch_encode[cl100k_base] ________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'cl100k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s def test_batch_encode(make_enc: Callable[[], tiktoken.Encoding]): 778s > enc = make_enc() 778s 778s tests/test_encoding.py:222: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s _____________________ test_hyp_batch_roundtrip[r50k_base] ______________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'r50k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s > @hypothesis.given(batch=st.lists(st.text())) 778s 778s tests/test_encoding.py:237: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s tests/test_encoding.py:240: in test_hyp_batch_roundtrip 778s enc = make_enc() 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s E Falsifying example: test_hyp_batch_roundtrip( 778s E make_enc=functools.partial(get_encoding, 'r50k_base'), 778s E batch=[], 778s E ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ____________________ test_hyp_batch_roundtrip[cl100k_base] _____________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'cl100k_base') 778s 778s @pytest.mark.parametrize("make_enc", ENCODING_FACTORIES) 778s > @hypothesis.given(batch=st.lists(st.text())) 778s 778s tests/test_encoding.py:237: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s tests/test_encoding.py:240: in test_hyp_batch_roundtrip 778s enc = make_enc() 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s E Falsifying example: test_hyp_batch_roundtrip( 778s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 778s E batch=[], 778s E ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ___________________________ test_encoding_for_model ____________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s def test_encoding_for_model(): 778s > enc = tiktoken.encoding_for_model("gpt2") 778s 778s tests/test_misc.py:8: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/model.py:105: in encoding_for_model 778s return get_encoding(encoding_name_for_model(model_name)) 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 778s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 778s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ________________________ test_hyp_offsets[cl100k_base] _________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s make_enc = functools.partial(, 'cl100k_base') 778s 778s @pytest.mark.parametrize("make_enc", SOME_ENCODING_FACTORIES) 778s > @hypothesis.given(data=st.data()) 778s 778s tests/test_offsets.py:29: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s tests/test_offsets.py:32: in test_hyp_offsets 778s enc = make_enc() 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s E Falsifying example: test_hyp_offsets( 778s E make_enc=functools.partial(get_encoding, 'cl100k_base'), 778s E data=data(...), 778s E ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ______________________________ test_basic_offsets ______________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/cl100k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/cl100k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s def test_basic_offsets(): 778s > enc = tiktoken.get_encoding("cl100k_base") 778s 778s tests/test_offsets.py:50: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:76: in cl100k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s _________________________________ test_pickle __________________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/encodings/r50k_base.tiktoken', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/encodings/r50k_base.tiktoken', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s def test_pickle(): 778s import pickle 778s 778s > enc_old = tiktoken.get_encoding("r50k_base") 778s 778s tests/test_pickle.py:7: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:34: in r50k_base 778s mergeable_ranks = load_tiktoken_bpe( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:144: in load_tiktoken_bpe 778s contents = read_file_cached(tiktoken_bpe_file, expected_hash) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s _________________________________ test_simple __________________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s def test_simple(): 778s # Note that there are more actual tests, they're just not currently public :-) 778s > enc = tiktoken.get_encoding("gpt2") 778s 778s tests/test_simple_public.py:9: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 778s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 778s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s ___________________________ test_encoding_for_model ____________________________ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s > sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:203: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:85: in create_connection 778s raise err 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s address = ('openaipublic.blob.core.windows.net', 443), timeout = None 778s source_address = None, socket_options = [(6, 1, 1)] 778s 778s def create_connection( 778s address: tuple[str, int], 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s source_address: tuple[str, int] | None = None, 778s socket_options: _TYPE_SOCKET_OPTIONS | None = None, 778s ) -> socket.socket: 778s """Connect to *address* and return the socket object. 778s 778s Convenience function. Connect to *address* (a 2-tuple ``(host, 778s port)``) and return the socket object. Passing the optional 778s *timeout* parameter will set the timeout on the socket instance 778s before attempting to connect. If no *timeout* is supplied, the 778s global default timeout setting returned by :func:`socket.getdefaulttimeout` 778s is used. If *source_address* is set it must be a tuple of (host, port) 778s for the socket to bind as a source address before making the connection. 778s An host of '' or port 0 tells the OS to use the default. 778s """ 778s 778s host, port = address 778s if host.startswith("["): 778s host = host.strip("[]") 778s err = None 778s 778s # Using the value from allowed_gai_family() in the context of getaddrinfo lets 778s # us select whether to work with IPv4 DNS records, IPv6 records, or both. 778s # The original create_connection function always returns all records. 778s family = allowed_gai_family() 778s 778s try: 778s host.encode("idna") 778s except UnicodeError: 778s raise LocationParseError(f"'{host}', label empty or too long") from None 778s 778s for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 778s af, socktype, proto, canonname, sa = res 778s sock = None 778s try: 778s sock = socket.socket(af, socktype, proto) 778s 778s # If provided, set socket level options before connecting. 778s _set_socket_options(sock, socket_options) 778s 778s if timeout is not _DEFAULT_TIMEOUT: 778s sock.settimeout(timeout) 778s if source_address: 778s sock.bind(source_address) 778s > sock.connect(sa) 778s E ConnectionRefusedError: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/util/connection.py:73: ConnectionRefusedError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', body = None 778s headers = {'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} 778s retries = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s redirect = False, assert_same_host = False 778s timeout = Timeout(connect=None, read=None, total=None), pool_timeout = None 778s release_conn = False, chunked = False, body_pos = None, preload_content = False 778s decode_content = False, response_kw = {} 778s parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/gpt-2/encodings/main/vocab.bpe', query=None, fragment=None) 778s destination_scheme = None, conn = None, release_this_conn = True 778s http_tunnel_required = False, err = None, clean_exit = False 778s 778s def urlopen( # type: ignore[override] 778s self, 778s method: str, 778s url: str, 778s body: _TYPE_BODY | None = None, 778s headers: typing.Mapping[str, str] | None = None, 778s retries: Retry | bool | int | None = None, 778s redirect: bool = True, 778s assert_same_host: bool = True, 778s timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT, 778s pool_timeout: int | None = None, 778s release_conn: bool | None = None, 778s chunked: bool = False, 778s body_pos: _TYPE_BODY_POSITION | None = None, 778s preload_content: bool = True, 778s decode_content: bool = True, 778s **response_kw: typing.Any, 778s ) -> BaseHTTPResponse: 778s """ 778s Get a connection from the pool and perform an HTTP request. This is the 778s lowest level call for making a request, so you'll need to specify all 778s the raw details. 778s 778s .. note:: 778s 778s More commonly, it's appropriate to use a convenience method 778s such as :meth:`request`. 778s 778s .. note:: 778s 778s `release_conn` will only behave as expected if 778s `preload_content=False` because we want to make 778s `preload_content=False` the default behaviour someday soon without 778s breaking backwards compatibility. 778s 778s :param method: 778s HTTP request method (such as GET, POST, PUT, etc.) 778s 778s :param url: 778s The URL to perform the request on. 778s 778s :param body: 778s Data to send in the request body, either :class:`str`, :class:`bytes`, 778s an iterable of :class:`str`/:class:`bytes`, or a file-like object. 778s 778s :param headers: 778s Dictionary of custom headers to send, such as User-Agent, 778s If-None-Match, etc. If None, pool headers are used. If provided, 778s these headers completely replace any pool-specific headers. 778s 778s :param retries: 778s Configure the number of retries to allow before raising a 778s :class:`~urllib3.exceptions.MaxRetryError` exception. 778s 778s Pass ``None`` to retry until you receive a response. Pass a 778s :class:`~urllib3.util.retry.Retry` object for fine-grained control 778s over different types of retries. 778s Pass an integer number to retry connection errors that many times, 778s but no other types of errors. Pass zero to never retry. 778s 778s If ``False``, then retries are disabled and any exception is raised 778s immediately. Also, instead of raising a MaxRetryError on redirects, 778s the redirect response will be returned. 778s 778s :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. 778s 778s :param redirect: 778s If True, automatically handle redirects (status codes 301, 302, 778s 303, 307, 308). Each redirect counts as a retry. Disabling retries 778s will disable redirect, too. 778s 778s :param assert_same_host: 778s If ``True``, will make sure that the host of the pool requests is 778s consistent else will raise HostChangedError. When ``False``, you can 778s use the pool on an HTTP proxy and request foreign hosts. 778s 778s :param timeout: 778s If specified, overrides the default timeout for this one 778s request. It may be a float (in seconds) or an instance of 778s :class:`urllib3.util.Timeout`. 778s 778s :param pool_timeout: 778s If set and the pool is set to block=True, then this method will 778s block for ``pool_timeout`` seconds and raise EmptyPoolError if no 778s connection is available within the time period. 778s 778s :param bool preload_content: 778s If True, the response's body will be preloaded into memory. 778s 778s :param bool decode_content: 778s If True, will attempt to decode the body based on the 778s 'content-encoding' header. 778s 778s :param release_conn: 778s If False, then the urlopen call will not release the connection 778s back into the pool once a response is received (but will release if 778s you read the entire contents of the response such as when 778s `preload_content=True`). This is useful if you're not preloading 778s the response's content immediately. You will need to call 778s ``r.release_conn()`` on the response ``r`` to return the connection 778s back into the pool. If None, it takes the value of ``preload_content`` 778s which defaults to ``True``. 778s 778s :param bool chunked: 778s If True, urllib3 will send the body using chunked transfer 778s encoding. Otherwise, urllib3 will send the body using the standard 778s content-length form. Defaults to False. 778s 778s :param int body_pos: 778s Position to seek to in file-like body in the event of a retry or 778s redirect. Typically this won't need to be set because urllib3 will 778s auto-populate the value when needed. 778s """ 778s parsed_url = parse_url(url) 778s destination_scheme = parsed_url.scheme 778s 778s if headers is None: 778s headers = self.headers 778s 778s if not isinstance(retries, Retry): 778s retries = Retry.from_int(retries, redirect=redirect, default=self.retries) 778s 778s if release_conn is None: 778s release_conn = preload_content 778s 778s # Check host 778s if assert_same_host and not self.is_same_host(url): 778s raise HostChangedError(self, url, retries) 778s 778s # Ensure that the URL we're connecting to is properly encoded 778s if url.startswith("/"): 778s url = to_str(_encode_target(url)) 778s else: 778s url = to_str(parsed_url.url) 778s 778s conn = None 778s 778s # Track whether `conn` needs to be released before 778s # returning/raising/recursing. Update this variable if necessary, and 778s # leave `release_conn` constant throughout the function. That way, if 778s # the function recurses, the original value of `release_conn` will be 778s # passed down into the recursive call, and its value will be respected. 778s # 778s # See issue #651 [1] for details. 778s # 778s # [1] 778s release_this_conn = release_conn 778s 778s http_tunnel_required = connection_requires_http_tunnel( 778s self.proxy, self.proxy_config, destination_scheme 778s ) 778s 778s # Merge the proxy headers. Only done when not using HTTP CONNECT. We 778s # have to copy the headers dict so we can safely change it without those 778s # changes being reflected in anyone else's copy. 778s if not http_tunnel_required: 778s headers = headers.copy() # type: ignore[attr-defined] 778s headers.update(self.proxy_headers) # type: ignore[union-attr] 778s 778s # Must keep the exception bound to a separate variable or else Python 3 778s # complains about UnboundLocalError. 778s err = None 778s 778s # Keep track of whether we cleanly exited the except block. This 778s # ensures we do proper cleanup in finally. 778s clean_exit = False 778s 778s # Rewind body position, if needed. Record current position 778s # for future rewinds in the event of a redirect/retry. 778s body_pos = set_file_position(body, body_pos) 778s 778s try: 778s # Request a connection from the queue. 778s timeout_obj = self._get_timeout(timeout) 778s conn = self._get_conn(timeout=pool_timeout) 778s 778s conn.timeout = timeout_obj.connect_timeout # type: ignore[assignment] 778s 778s # Is this a closed/new connection that requires CONNECT tunnelling? 778s if self.proxy is not None and http_tunnel_required and conn.is_closed: 778s try: 778s self._prepare_proxy(conn) 778s except (BaseSSLError, OSError, SocketTimeout) as e: 778s self._raise_timeout( 778s err=e, url=self.proxy.url, timeout_value=conn.timeout 778s ) 778s raise 778s 778s # If we're going to release the connection in ``finally:``, then 778s # the response doesn't need to know about the connection. Otherwise 778s # it will also try to release it and we'll have a double-release 778s # mess. 778s response_conn = conn if not release_conn else None 778s 778s # Make the request on the HTTPConnection object 778s > response = self._make_request( 778s conn, 778s method, 778s url, 778s timeout=timeout_obj, 778s body=body, 778s headers=headers, 778s chunked=chunked, 778s retries=retries, 778s response_conn=response_conn, 778s preload_content=preload_content, 778s decode_content=decode_content, 778s **response_kw, 778s ) 778s 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:791: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:492: in _make_request 778s raise new_e 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:468: in _make_request 778s self._validate_conn(conn) 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1097: in _validate_conn 778s conn.connect() 778s /usr/lib/python3/dist-packages/urllib3/connection.py:611: in connect 778s self.sock = sock = self._new_conn() 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s 778s def _new_conn(self) -> socket.socket: 778s """Establish a socket connection and set nodelay settings on it. 778s 778s :return: New socket connection. 778s """ 778s try: 778s sock = connection.create_connection( 778s (self._dns_host, self.port), 778s self.timeout, 778s source_address=self.source_address, 778s socket_options=self.socket_options, 778s ) 778s except socket.gaierror as e: 778s raise NameResolutionError(self.host, self, e) from e 778s except SocketTimeout as e: 778s raise ConnectTimeoutError( 778s self, 778s f"Connection to {self.host} timed out. (connect timeout={self.timeout})", 778s ) from e 778s 778s except OSError as e: 778s > raise NewConnectionError( 778s self, f"Failed to establish a new connection: {e}" 778s ) from e 778s E urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused 778s 778s /usr/lib/python3/dist-packages/urllib3/connection.py:218: NewConnectionError 778s 778s The above exception was the direct cause of the following exception: 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s > resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:667: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/urllib3/connectionpool.py:845: in urlopen 778s retries = retries.increment( 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = Retry(total=0, connect=None, read=False, redirect=None, status=None) 778s method = 'GET', url = '/gpt-2/encodings/main/vocab.bpe', response = None 778s error = NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused') 778s _pool = 778s _stacktrace = 778s 778s def increment( 778s self, 778s method: str | None = None, 778s url: str | None = None, 778s response: BaseHTTPResponse | None = None, 778s error: Exception | None = None, 778s _pool: ConnectionPool | None = None, 778s _stacktrace: TracebackType | None = None, 778s ) -> Retry: 778s """Return a new Retry object with incremented retry counters. 778s 778s :param response: A response object, or None, if the server did not 778s return a response. 778s :type response: :class:`~urllib3.response.BaseHTTPResponse` 778s :param Exception error: An error encountered during the request, or 778s None if the response was received successfully. 778s 778s :return: A new ``Retry`` object. 778s """ 778s if self.total is False and error: 778s # Disabled, indicate to re-raise the error. 778s raise reraise(type(error), error, _stacktrace) 778s 778s total = self.total 778s if total is not None: 778s total -= 1 778s 778s connect = self.connect 778s read = self.read 778s redirect = self.redirect 778s status_count = self.status 778s other = self.other 778s cause = "unknown" 778s status = None 778s redirect_location = None 778s 778s if error and self._is_connection_error(error): 778s # Connect retry? 778s if connect is False: 778s raise reraise(type(error), error, _stacktrace) 778s elif connect is not None: 778s connect -= 1 778s 778s elif error and self._is_read_error(error): 778s # Read retry? 778s if read is False or method is None or not self._is_method_retryable(method): 778s raise reraise(type(error), error, _stacktrace) 778s elif read is not None: 778s read -= 1 778s 778s elif error: 778s # Other retry? 778s if other is not None: 778s other -= 1 778s 778s elif response and response.get_redirect_location(): 778s # Redirect retry? 778s if redirect is not None: 778s redirect -= 1 778s cause = "too many redirects" 778s response_redirect_location = response.get_redirect_location() 778s if response_redirect_location: 778s redirect_location = response_redirect_location 778s status = response.status 778s 778s else: 778s # Incrementing because of a server error like a 500 in 778s # status_forcelist and the given method is in the allowed_methods 778s cause = ResponseError.GENERIC_ERROR 778s if response and response.status: 778s if status_count is not None: 778s status_count -= 1 778s cause = ResponseError.SPECIFIC_ERROR.format(status_code=response.status) 778s status = response.status 778s 778s history = self.history + ( 778s RequestHistory(method, url, error, status, redirect_location), 778s ) 778s 778s new_retry = self.new( 778s total=total, 778s connect=connect, 778s read=read, 778s redirect=redirect, 778s status=status_count, 778s other=other, 778s history=history, 778s ) 778s 778s if new_retry.is_exhausted(): 778s reason = error or ResponseError(cause) 778s > raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 778s 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')) 778s 778s /usr/lib/python3/dist-packages/urllib3/util/retry.py:517: MaxRetryError 778s 778s During handling of the above exception, another exception occurred: 778s 778s def test_encoding_for_model(): 778s > enc = tiktoken.encoding_for_model("gpt2") 778s 778s tests/test_simple_public.py:26: 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s /usr/lib/python3/dist-packages/tiktoken/model.py:105: in encoding_for_model 778s return get_encoding(encoding_name_for_model(model_name)) 778s /usr/lib/python3/dist-packages/tiktoken/registry.py:86: in get_encoding 778s enc = Encoding(**constructor()) 778s /usr/lib/python3/dist-packages/tiktoken_ext/openai_public.py:18: in gpt2 778s mergeable_ranks = data_gym_to_mergeable_bpe_ranks( 778s /usr/lib/python3/dist-packages/tiktoken/load.py:103: in data_gym_to_mergeable_bpe_ranks 778s vocab_bpe_contents = read_file_cached(vocab_bpe_file, vocab_bpe_hash).decode() 778s /usr/lib/python3/dist-packages/tiktoken/load.py:63: in read_file_cached 778s contents = read_file(blobpath) 778s /usr/lib/python3/dist-packages/tiktoken/load.py:24: in read_file 778s resp = requests.get(blobpath) 778s /usr/lib/python3/dist-packages/requests/api.py:73: in get 778s return request("get", url, params=params, **kwargs) 778s /usr/lib/python3/dist-packages/requests/api.py:59: in request 778s return session.request(method=method, url=url, **kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:589: in request 778s resp = self.send(prep, **send_kwargs) 778s /usr/lib/python3/dist-packages/requests/sessions.py:703: in send 778s r = adapter.send(request, **kwargs) 778s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 778s 778s self = 778s request = , stream = False 778s timeout = Timeout(connect=None, read=None, total=None), verify = True 778s cert = None, proxies = OrderedDict() 778s 778s def send( 778s self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None 778s ): 778s """Sends PreparedRequest object. Returns Response object. 778s 778s :param request: The :class:`PreparedRequest ` being sent. 778s :param stream: (optional) Whether to stream the request content. 778s :param timeout: (optional) How long to wait for the server to send 778s data before giving up, as a float, or a :ref:`(connect timeout, 778s read timeout) ` tuple. 778s :type timeout: float or tuple or urllib3 Timeout object 778s :param verify: (optional) Either a boolean, in which case it controls whether 778s we verify the server's TLS certificate, or a string, in which case it 778s must be a path to a CA bundle to use 778s :param cert: (optional) Any user-provided SSL certificate to be trusted. 778s :param proxies: (optional) The proxies dictionary to apply to the request. 778s :rtype: requests.Response 778s """ 778s 778s try: 778s conn = self.get_connection_with_tls_context( 778s request, verify, proxies=proxies, cert=cert 778s ) 778s except LocationValueError as e: 778s raise InvalidURL(e, request=request) 778s 778s self.cert_verify(conn, request.url, verify, cert) 778s url = self.request_url(request, proxies) 778s self.add_headers( 778s request, 778s stream=stream, 778s timeout=timeout, 778s verify=verify, 778s cert=cert, 778s proxies=proxies, 778s ) 778s 778s chunked = not (request.body is None or "Content-Length" in request.headers) 778s 778s if isinstance(timeout, tuple): 778s try: 778s connect, read = timeout 778s timeout = TimeoutSauce(connect=connect, read=read) 778s except ValueError: 778s raise ValueError( 778s f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " 778s f"or a single float to set both timeouts to the same value." 778s ) 778s elif isinstance(timeout, TimeoutSauce): 778s pass 778s else: 778s timeout = TimeoutSauce(connect=timeout, read=timeout) 778s 778s try: 778s resp = conn.urlopen( 778s method=request.method, 778s url=url, 778s body=request.body, 778s headers=request.headers, 778s redirect=False, 778s assert_same_host=False, 778s preload_content=False, 778s decode_content=False, 778s retries=self.max_retries, 778s timeout=timeout, 778s chunked=chunked, 778s ) 778s 778s except (ProtocolError, OSError) as err: 778s raise ConnectionError(err, request=request) 778s 778s except MaxRetryError as e: 778s if isinstance(e.reason, ConnectTimeoutError): 778s # TODO: Remove this in 3.0.0: see #2811 778s if not isinstance(e.reason, NewConnectionError): 778s raise ConnectTimeout(e, request=request) 778s 778s if isinstance(e.reason, ResponseError): 778s raise RetryError(e, request=request) 778s 778s if isinstance(e.reason, _ProxyError): 778s raise ProxyError(e, request=request) 778s 778s if isinstance(e.reason, _SSLError): 778s # This branch is for urllib3 v1.22 and later. 778s raise SSLError(e, request=request) 778s 778s > raise ConnectionError(e, request=request) 778s 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')) 778s 778s /usr/lib/python3/dist-packages/requests/adapters.py:700: ConnectionError 778s =========================== short test summary info ============================ 778s FAILED tests/test_encoding.py::test_simple - requests.exceptions.ConnectionEr... 778s FAILED tests/test_encoding.py::test_simple_repeated - requests.exceptions.Con... 778s FAILED tests/test_encoding.py::test_simple_regex - requests.exceptions.Connec... 778s FAILED tests/test_encoding.py::test_basic_encode - requests.exceptions.Connec... 778s FAILED tests/test_encoding.py::test_encode_empty - requests.exceptions.Connec... 778s FAILED tests/test_encoding.py::test_encode_bytes - requests.exceptions.Connec... 778s FAILED tests/test_encoding.py::test_encode_surrogate_pairs - requests.excepti... 778s FAILED tests/test_encoding.py::test_catastrophically_repetitive[r50k_base] - ... 778s FAILED tests/test_encoding.py::test_catastrophically_repetitive[cl100k_base] 778s FAILED tests/test_encoding.py::test_basic_roundtrip[r50k_base] - requests.exc... 778s FAILED tests/test_encoding.py::test_basic_roundtrip[cl100k_base] - requests.e... 778s FAILED tests/test_encoding.py::test_hyp_roundtrip[r50k_base] - requests.excep... 778s FAILED tests/test_encoding.py::test_hyp_roundtrip[cl100k_base] - requests.exc... 778s FAILED tests/test_encoding.py::test_single_token_roundtrip[r50k_base] - reque... 778s FAILED tests/test_encoding.py::test_single_token_roundtrip[cl100k_base] - req... 778s FAILED tests/test_encoding.py::test_special_token - requests.exceptions.Conne... 778s FAILED tests/test_encoding.py::test_hyp_special_ordinary[r50k_base] - request... 778s FAILED tests/test_encoding.py::test_hyp_special_ordinary[cl100k_base] - reque... 778s FAILED tests/test_encoding.py::test_batch_encode[r50k_base] - requests.except... 778s FAILED tests/test_encoding.py::test_batch_encode[cl100k_base] - requests.exce... 778s FAILED tests/test_encoding.py::test_hyp_batch_roundtrip[r50k_base] - requests... 778s FAILED tests/test_encoding.py::test_hyp_batch_roundtrip[cl100k_base] - reques... 778s FAILED tests/test_misc.py::test_encoding_for_model - requests.exceptions.Conn... 778s FAILED tests/test_offsets.py::test_hyp_offsets[cl100k_base] - requests.except... 778s FAILED tests/test_offsets.py::test_basic_offsets - requests.exceptions.Connec... 778s FAILED tests/test_pickle.py::test_pickle - requests.exceptions.ConnectionErro... 778s FAILED tests/test_simple_public.py::test_simple - requests.exceptions.Connect... 778s FAILED tests/test_simple_public.py::test_encoding_for_model - requests.except... 778s ======================== 28 failed, 2 passed in 34.06s ========================= 778s autopkgtest [20:43:57]: test pybuild-autopkgtest: -----------------------] 779s pybuild-autopkgtest FAIL non-zero exit status 25 779s autopkgtest [20:43:58]: test pybuild-autopkgtest: - - - - - - - - - - results - - - - - - - - - - 779s autopkgtest [20:43:58]: @@@@@@@@@@@@@@@@@@@@ summary 779s pybuild-autopkgtest FAIL non-zero exit status 25 790s virt: nova [W] Skipping flock for amd64 790s virt: Creating nova instance adt-plucky-amd64-tiktoken-20241123-203058-juju-7f2275-prod-proposed-migration-environment-2-098cac6c-a9a9-4701-963a-30a2bc760522 from image adt/ubuntu-plucky-amd64-server-20241119.img (UUID 2e5306de-7efa-448c-bc27-5518979e66f0)...