Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 730597 Details for
Bug 806671
dev-python/uvicorn-0.14.0-r1 fails tests
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
build.log
build.log (text/plain), 412.02 KB, created by
Agostino Sarubbo
on 2021-08-06 06:36:19 UTC
(
hide
)
Description:
build.log
Filename:
MIME Type:
Creator:
Agostino Sarubbo
Created:
2021-08-06 06:36:19 UTC
Size:
412.02 KB
patch
obsolete
> * Package: dev-python/uvicorn-0.14.0-r1 > * Repository: gentoo > * Maintainer: python@gentoo.org > * Upstream: https://github.com/encode/uvicorn/issues > * USE: abi_x86_64 amd64 elibc_glibc kernel_linux python_targets_python3_8 python_targets_python3_9 test userland_GNU > * FEATURES: network-sandbox preserve-libs sandbox test userpriv usersandbox > > >@@@@@ PLEASE PAY ATTENTION HERE!!! @@@@@ >This information may help you to understand if this is a duplicate or if this bug exists after you pushed a fix; >This ebuild was merged at the following commit: >https://github.com/gentoo/gentoo/commit/a8fa5fd7d0dd55197ac350a46fcce7be88c6f39e (Thu Aug 5 18:52:35 UTC 2021) >@@@@@ END @@@@@ > > > >@@@@@ PLEASE PAY ATTENTION HERE!!! @@@@@ >This ebuild was merged (directly or as a dependency) because of the following commit: >https://github.com/gentoo/gentoo/commit/52aface3f6bb21f71ae6c11b8f4c3c20347aa1e0 >@@@@@ END @@@@@ > > > >################## ># emerge --info: # >################## >Portage 3.0.20 (python 3.9.6-final-0, default/linux/amd64/17.1, gcc-11.2.0, glibc-2.33-r5, 4.19.174-gentoo x86_64) >================================================================= >System uname: Linux-4.19.174-gentoo-x86_64-Intel-R-_Xeon-R-_CPU_E5-2650_v4_@_2.20GHz-with-glibc2.33 >KiB Mem: 264046488 total, 123752288 free >KiB Swap: 0 total, 0 free >sh bash 5.1_p8 >ld GNU ld (Gentoo 2.36.1 p5) 2.36.1 >app-shells/bash: 5.1_p8::gentoo >dev-lang/perl: 5.34.0-r1::gentoo >dev-lang/python: 2.7.18_p11::gentoo, 3.8.11::gentoo, 3.9.6_p1::gentoo, 3.10.0_rc1_p1::gentoo >dev-lang/rust: 1.54.0::gentoo >dev-util/cmake: 3.21.1::gentoo >sys-apps/baselayout: 2.7-r3::gentoo >sys-apps/openrc: 0.43.3::gentoo >sys-apps/sandbox: 2.24::gentoo >sys-devel/autoconf: 2.13-r1::gentoo, 2.71-r1::gentoo >sys-devel/automake: 1.16.4::gentoo >sys-devel/binutils: 2.36.1-r2::gentoo >sys-devel/gcc: 11.2.0::gentoo >sys-devel/gcc-config: 2.4::gentoo >sys-devel/libtool: 2.4.6-r6::gentoo >sys-devel/make: 4.3::gentoo >sys-kernel/linux-headers: 5.13::gentoo (virtual/os-headers) >sys-libs/glibc: 2.33-r5::gentoo >Repositories: > >gentoo > location: /usr/portage > sync-type: rsync > sync-uri: rsync://rsync.gentoo.org/gentoo-portage > priority: -1000 > sync-rsync-verify-metamanifest: yes > sync-rsync-verify-jobs: 1 > sync-rsync-extra-opts: > sync-rsync-verify-max-age: 24 > >ACCEPT_KEYWORDS="amd64 ~amd64" >ACCEPT_LICENSE="* BSD" >CBUILD="x86_64-pc-linux-gnu" >CFLAGS="-O2 -pipe -march=x86-64 -frecord-gcc-switches" >CHOST="x86_64-pc-linux-gnu" >CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt" >CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo" >CXXFLAGS="-O2 -pipe -march=x86-64 -frecord-gcc-switches" >DISTDIR="/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/distdir" >EMERGE_DEFAULT_OPTS="--with-bdeps=y -1 -k -b" >ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR" >FCFLAGS="-O2 -pipe -march=x86-64 -frecord-gcc-switches" >FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms sign split-log strict test unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" >FFLAGS="-O2 -pipe -march=x86-64 -frecord-gcc-switches" >GENTOO_MIRRORS="http://distfiles.gentoo.org" >LANG="en_US.utf8" >LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0" >MAKEOPTS="-j24" >PKGDIR="/root/.packages" >PORTAGE_CONFIGROOT="/" >PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" >PORTAGE_TMPDIR="/var/tmp" >USE="acl amd64 bzip2 cli crypt dri elogind fortran gdbm iconv ipv6 jumbo-build libglvnd libtirpc multilib native-symlinks ncurses nls nptl openmp pam pcre readline seccomp split-usr ssl tcpd test unicode xattr zlib" ABI_X86="64" ELIBC="glibc" KERNEL="linux" PYTHON_TARGETS="python3_8 python3_9" USERLAND="GNU" >Unset: CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS > > > > > >############################## ># emerge history (qlop -mv): # >############################## >2021-08-05T20:55:50 >>> dev-python/typing-extensions-3.10.0.0 >2021-08-05T20:55:53 >>> dev-python/zipp-3.5.0 >2021-08-05T20:55:52 >>> dev-python/h11-0.12.0 >2021-08-05T20:55:56 >>> dev-python/asgiref-3.4.1 >2021-08-05T20:56:04 >>> dev-python/importlib_metadata-4.6.3 >2021-08-05T20:56:15 >>> dev-python/click-8.0.1 >2021-08-05T20:56:21 >>> dev-python/uvicorn-0.14.0-r1 >2021-08-05T20:56:49 >>> dev-python/sniffio-1.2.0 >2021-08-05T20:56:50 >>> dev-python/python-dotenv-0.19.0 >2021-08-05T20:56:48 >>> dev-libs/libyaml-0.2.5 >2021-08-05T20:56:52 >>> dev-python/wsproto-1.0.0 >2021-08-05T20:56:53 >>> dev-python/iniconfig-1.1.1 >2021-08-05T20:56:54 >>> dev-python/more-itertools-8.8.0 >2021-08-05T20:56:55 >>> dev-python/py-1.10.0 >2021-08-05T20:56:57 >>> dev-python/pyparsing-2.4.7-r1 >2021-08-05T20:56:59 >>> dev-python/rfc3986-1.5.0 >2021-08-05T20:57:00 >>> dev-python/anyio-3.2.1 >2021-08-05T20:56:58 >>> dev-python/pluggy-0.13.1-r1 >2021-08-05T20:57:01 >>> dev-python/hyperframe-6.0.1 >2021-08-05T20:57:03 >>> dev-python/hpack-4.0.0 >2021-08-05T20:57:04 >>> dev-python/ply-3.11-r1 >2021-08-05T20:57:06 >>> dev-python/namespace-zope-1-r1 >2021-08-05T20:57:08 >>> dev-python/cython-0.29.24 >2021-08-05T20:57:05 >>> dev-python/websockets-9.1-r1 >2021-08-05T20:57:40 >>> dev-python/packaging-21.0 >2021-08-05T20:57:58 >>> dev-python/hyper-h2-4.0.0 >2021-08-05T20:58:01 >>> dev-python/pycparser-2.20-r1 >2021-08-05T20:58:05 >>> dev-python/zope-interface-5.4.0 >2021-08-05T20:58:09 >>> dev-python/pyyaml-5.4.1 >2021-08-05T20:58:27 >>> dev-python/httpcore-0.13.6 >2021-08-05T20:58:30 >>> dev-python/cffi-1.14.6 >2021-08-05T20:58:34 >>> dev-python/attrs-21.2.0 >2021-08-05T20:58:49 >>> dev-python/cryptography-3.4.7-r2 >2021-08-05T20:58:52 >>> dev-python/pytest-6.2.4-r1 >2021-08-05T20:59:01 >>> dev-python/trustme-0.8.0 >2021-08-05T20:59:05 >>> dev-python/pytest-asyncio-0.15.1 >2021-08-05T20:58:45 >>> dev-python/httpx-0.18.2 >2021-08-05T20:59:07 >>> dev-python/pytest-mock-3.6.1 > > > > >####################################### ># installed packages (qlist -ICvUSS): # >####################################### >acct-group/audio-0-r1:0 >acct-group/cdrom-0-r1:0 >acct-group/dialout-0-r1:0 >acct-group/disk-0-r1:0 >acct-group/input-0-r1:0 >acct-group/kmem-0-r1:0 >acct-group/kvm-0-r1:0 >acct-group/lp-0-r1:0 >acct-group/man-0-r1:0 >acct-group/messagebus-0-r1:0 >acct-group/polkitd-0-r1:0 >acct-group/portage-0:0 >acct-group/render-0-r1:0 >acct-group/sshd-0-r1:0 >acct-group/tape-0-r1:0 >acct-group/tty-0-r1:0 >acct-group/video-0-r1:0 >acct-user/man-1-r1:0 >acct-user/messagebus-0-r1:0 >acct-user/polkitd-0-r1:0 >acct-user/portage-0:0 >acct-user/sshd-0-r1:0 >app-admin/eselect-1.4.17:0 -doc -emacs -vim-syntax >app-admin/perl-cleaner-2.30:0 >app-arch/bzip2-1.0.8-r1:0/1 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 split-usr -static -static-libs >app-arch/gzip-1.10:0 -pic -static >app-arch/libarchive-3.5.1-r1:0/13 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 acl -blake2 bzip2 e2fsprogs -expat iconv -lz4 lzma -lzo -nettle -static-libs xattr zlib -zstd >app-arch/tar-1.34:0 acl -minimal nls -selinux xattr >app-arch/unzip-6.0_p26:0 bzip2 -natspec unicode >app-arch/xz-utils-5.2.5-r1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 extra-filters nls split-usr -static-libs >app-arch/zstd-1.5.0:0/1 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -lz4 -static-libs threads >app-crypt/gnupg-2.2.28:0 bzip2 -doc -ldap nls readline -selinux smartcard ssl -tofu -tools -usb -user-socket -wks-server >app-crypt/gpgme-1.16.0:1/11 -common-lisp cxx -python -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -qt5 -static-libs >app-crypt/libb2-0.98.1-r3:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -native-cflags openmp -static-libs >app-crypt/libmd-1.0.3-r1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 >app-crypt/openpgp-keys-gentoo-release-20200704:0 -test >app-crypt/pinentry-1.1.1-r1:0 -caps -efl -emacs -gnome-keyring -gtk ncurses -qt5 >app-crypt/rhash-1.4.2:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -debug nls ssl -static-libs >app-editors/nano-5.8-r2:0 -debug -justify -magic -minimal ncurses nls spell split-usr -static unicode >app-eselect/eselect-fontconfig-1.1-r1:0 >app-eselect/eselect-iptables-20200508:0 >app-eselect/eselect-lib-bin-symlink-0.1.1-r1:0 >app-eselect/eselect-pinentry-0.7.2:0 >app-eselect/eselect-rust-20210703:0 >app-i18n/man-pages-ja-20180315-r1:0 >app-i18n/man-pages-l10n-4.10.0:0 l10n_de l10n_es l10n_fr l10n_it l10n_nl l10n_pl l10n_pt-BR l10n_ro >app-i18n/man-pages-ru-5.03.2390.2390.20191017-r1:0 >app-i18n/man-pages-zh_CN-1.6.3.2:0 >app-misc/c_rehash-1.7-r1:0 >app-misc/ca-certificates-20210119.3.66:0 -cacert >app-misc/editor-wrapper-4-r1:0 >app-misc/mime-types-9:0 >app-misc/pax-utils-1.3.3:0 -caps -debug -python -python_single_target_python3_10 -python_single_target_python3_8 python_single_target_python3_9 seccomp >app-misc/tmux-3.2a:0 -debug -selinux -utempter -vim-syntax >app-portage/eix-0.35.2:0 -debug -doc nls -sqlite >app-portage/elt-patches-20201205:0 >app-portage/gemato-16.2:0 gpg python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test -tools >app-portage/gentoolkit-0.5.1:0 python_targets_pypy3 python_targets_python3_8 python_targets_python3_9 -test >app-portage/portage-utils-0.92:0 nls openmp qmanifest qtegrity -static >app-shells/bash-5.1_p8:0 -afs -bashlogger -examples -mem-scramble net nls -plugins readline >app-shells/push-3.4:0 >app-shells/quoter-4.2:0 >app-text/ansifilter-2.18:0 -qt5 >app-text/build-docbook-catalog-1.21:0 >app-text/docbook-xml-dtd-4.5-r2:4.5 >app-text/docbook-xml-dtd-4.4-r3:4.4 >app-text/docbook-xml-dtd-4.2-r3:4.2 >app-text/docbook-xml-dtd-4.1.2-r7:4.1.2 >app-text/docbook-xsl-stylesheets-1.79.1-r2:0 -ruby >app-text/manpager-1:0 >app-text/opensp-1.5.2-r6:0 -doc nls -static-libs -test >app-text/po4a-0.63-r1:0 -test >app-text/sgml-common-0.6.3-r7:0 >app-text/xmlto-0.0.28-r6:0 -latex -text >dev-db/sqlite-3.35.5:3 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -debug -doc -icu readline -secure-delete -static-libs -tcl -test -tools >dev-lang/perl-5.34.0-r1:0/5.34 -berkdb -debug -doc gdbm -ithreads -minimal >dev-lang/python-3.10.0_rc1_p1:3.10 -bluetooth -build -examples gdbm -hardened ipv6 ncurses readline sqlite ssl -test -tk -verify-sig -wininst xml >dev-lang/python-3.9.6_p1:3.9 -bluetooth -build -examples gdbm -hardened ipv6 ncurses readline sqlite ssl -test -tk -verify-sig -wininst xml >dev-lang/python-3.8.11:3.8 -bluetooth -build -examples gdbm -hardened ipv6 ncurses readline sqlite ssl -test -tk -verify-sig -wininst xml >dev-lang/python-2.7.18_p11:2.7 -berkdb -bluetooth -build -examples gdbm -hardened ipv6 ncurses readline sqlite ssl threads -tk -verify-sig wide-unicode -wininst xml >dev-lang/python-exec-2.4.8:2 native-symlinks python_targets_pypy3 python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-lang/python-exec-conf-2.4.6:2 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 >dev-lang/rust-1.54.0:stable/1.54 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -clippy cpu_flags_x86_sse2 -debug -doc -llvm_targets_AArch64 -llvm_targets_AMDGPU -llvm_targets_ARM -llvm_targets_AVR -llvm_targets_BPF -llvm_targets_Hexagon -llvm_targets_Lanai -llvm_targets_Mips -llvm_targets_MSP430 -llvm_targets_NVPTX -llvm_targets_PowerPC -llvm_targets_RISCV -llvm_targets_Sparc -llvm_targets_SystemZ -llvm_targets_WebAssembly llvm_targets_X86 -llvm_targets_XCore -miri -nightly -parallel-compiler -rls rustfmt -system-bootstrap -system-llvm -test -verify-sig -wasm >dev-lang/spidermonkey-78.12.0:78 -clang -cpu_flags_arm_neon -debug jit -lto -test >dev-lang/tcl-8.6.11:0/8.6 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -debug threads >dev-libs/elfutils-0.185:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 bzip2 -lzma nls -static-libs -test -threads utils -valgrind -zstd >dev-libs/expat-2.4.1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -examples split-usr -static-libs unicode >dev-libs/glib-2.68.3-r1:2 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -dbus -debug elf -fam -gtk-doc mime -selinux -static-libs -sysprof -systemtap -test -utils xattr >dev-libs/gmp-6.2.1-r1:0/10.4 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 asm cxx -doc -pic -static-libs >dev-libs/gobject-introspection-1.68.0:0 -doctool -gtk-doc -python_single_target_python3_10 -python_single_target_python3_8 python_single_target_python3_9 -test >dev-libs/gobject-introspection-common-1.68.0:0 >dev-libs/icu-69.1:0/69.1 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -debug -doc -examples -static-libs >dev-libs/isl-0.24:0/23 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -static-libs >dev-libs/jsoncpp-1.9.4:0/24 -doc -test >dev-libs/libassuan-2.5.5:0 >dev-libs/libbsd-0.11.3:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -static-libs >dev-libs/libevent-2.1.12:0/2.1-7 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 clock-gettime -debug -malloc-replacement ssl -static-libs -test threads -verbose-debug >dev-libs/libffi-3.4.2:0/8 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -debug -exec-static-trampoline -pax-kernel -static-libs -test >dev-libs/libgcrypt-1.9.3:0/20 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 asm -cpu_flags_arm_neon -cpu_flags_x86_aes -cpu_flags_x86_avx -cpu_flags_x86_avx2 -cpu_flags_x86_padlock -cpu_flags_x86_sha -cpu_flags_x86_sse4_1 -doc -o-flag-munging -static-libs >dev-libs/libgpg-error-1.42:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -common-lisp nls -static-libs >dev-libs/libksba-1.6.0:0 -static-libs >dev-libs/libltdl-2.4.6:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -static-libs >dev-libs/libpcre-8.45:3 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 bzip2 cxx jit -libedit pcre16 pcre32 readline recursion-limit split-usr -static-libs unicode zlib >dev-libs/libpcre2-10.37-r2:0/3 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 bzip2 jit -libedit pcre16 pcre32 readline recursion-limit split-usr -static-libs unicode zlib >dev-libs/libpipeline-1.5.3:0 -static-libs -test >dev-libs/libtasn1-4.17.0:0/6 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -doc -static-libs -test -valgrind >dev-libs/libunistring-0.9.10-r1:0/2 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -doc -static-libs >dev-libs/libuv-1.41.1:0/1 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 >dev-libs/libxml2-2.9.12-r5:2 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -debug -examples -icu ipv6 -lzma python python_targets_python3_8 python_targets_python3_9 readline -static-libs -test -verify-sig >dev-libs/libxslt-1.1.34-r1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 crypt -debug -examples -static-libs -verify-sig >dev-libs/libyaml-0.2.5:0 -doc -static-libs -test >dev-libs/lzo-2.10:2 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -examples split-usr -static-libs >dev-libs/mpc-1.2.1:0/3 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -static-libs >dev-libs/mpfr-4.1.0:0/6 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -static-libs >dev-libs/nettle-3.7.3:0/8-6 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 asm -cpu_flags_arm_neon -cpu_flags_x86_aes -cpu_flags_x86_sha -doc gmp -static-libs -test >dev-libs/npth-1.6-r1:0 >dev-libs/nspr-4.32:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -debug >dev-libs/openssl-1.1.1k-r1:0/1.1 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 asm -bindist cpu_flags_x86_sse2 -rfc3779 -sctp -sslv3 -static-libs -test -tls-compression -tls-heartbeat -vanilla >dev-libs/popt-1.18:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 nls -static-libs >dev-perl/Encode-EUCJPASCII-0.30.0-r1:0 -test >dev-perl/Encode-HanExtra-0.230.0-r3:0 >dev-perl/Encode-Locale-1.50.0:0 -test >dev-perl/File-Listing-6.140.0:0 -test >dev-perl/HTML-Parser-3.760.0:0 -test >dev-perl/HTML-Tagset-3.200.0-r2:0 >dev-perl/HTTP-Cookies-6.100.0:0 -test >dev-perl/HTTP-Date-6.50.0:0 >dev-perl/HTTP-Message-6.320.0:0 -test -test >dev-perl/HTTP-Negotiate-6.10.0-r1:0 >dev-perl/IO-HTML-1.4.0:0 -test >dev-perl/IO-Socket-INET6-2.720.0-r1:0 >dev-perl/IO-Socket-SSL-2.71.0:0 -examples -idn -test >dev-perl/libwww-perl-6.550.0:0 ssl -test >dev-perl/Locale-gettext-1.70.0:0 >dev-perl/LWP-MediaTypes-6.40.0:0 -test >dev-perl/LWP-Protocol-https-6.100.0:0 -test >dev-perl/MIME-Charset-1.12.2:0 l10n_ja l10n_zh >dev-perl/Module-Build-0.423.100:0 -test >dev-perl/Mozilla-CA-20999999:0 >dev-perl/Net-HTTP-6.210.0:0 -minimal -test >dev-perl/Net-SSLeay-1.900.0:0 -examples -examples -minimal -test >dev-perl/Pod-Parser-1.630.0-r1:0 -test >dev-perl/SGMLSpm-1.1-r1:0 >dev-perl/Socket6-0.280.0:0 >dev-perl/TermReadKey-2.370.0:0 -examples >dev-perl/Text-CharWidth-0.40.0-r1:0 >dev-perl/Text-WrapI18N-0.60.0-r1:0 >dev-perl/TimeDate-2.330.0:0 >dev-perl/Try-Tiny-0.300.0:0 -minimal -test >dev-perl/Unicode-LineBreak-2019.1.0:0 >dev-perl/URI-1.730.0:0 -test >dev-perl/WWW-RobotRules-6.20.0-r1:0 >dev-perl/XML-Parser-2.460.0:0 >dev-perl/YAML-Tiny-1.730.0:0 -minimal -test >dev-python/anyio-3.2.1:0 -doc -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/asgiref-3.4.1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/attrs-21.2.0:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/certifi-10001-r1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/cffi-1.14.6:0/1.14.6 -doc -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/charset_normalizer-2.0.3:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/click-8.0.1:0 -doc -examples python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/cryptography-3.4.7-r2:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/cython-0.29.24:0 -doc -emacs python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/h11-0.12.0:0 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/hpack-4.0.0:0 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/httpcore-0.13.6:0 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/httpx-0.18.2:0 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/hyper-h2-4.0.0:0 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/hyperframe-6.0.1:0 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/idna-3.2:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 >dev-python/importlib_metadata-4.6.3:0 -doc python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/iniconfig-1.1.1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/jinja-3.0.1:0 -doc -examples python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/markupsafe-2.0.1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/more-itertools-8.8.0:0 -doc python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/namespace-zope-1-r1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 >dev-python/packaging-21.0:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/pluggy-0.13.1-r1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/ply-3.11-r1:0/3.11 -examples python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 >dev-python/py-1.10.0:0 -doc python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/pycparser-2.20-r1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 >dev-python/pyparsing-2.4.7-r1:0 -examples python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 >dev-python/pypy3-7.3.4_p2:0/pypy37-pp73 bzip2 gdbm jit ncurses -sqlite -test -tk >dev-python/pypy3-exe-7.3.4:7.3.4 bzip2 -cpu_flags_x86_sse2 jit -low-memory ncurses >dev-python/PySocks-1.7.1-r1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 >dev-python/pytest-6.2.4-r1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/pytest-asyncio-0.15.1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/pytest-mock-3.6.1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/python-dotenv-0.19.0:0 python_targets_python3_8 python_targets_python3_9 -test >dev-python/pyyaml-5.4.1:0 -examples libyaml python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/requests-2.26.0:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -socks5 -test >dev-python/rfc3986-1.5.0:0 -idna python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/setuptools-57.4.0-r1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/setuptools_scm-6.0.1-r1:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/sniffio-1.2.0:0 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/toml-0.10.2:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test -test >dev-python/trustme-0.8.0:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/typing-extensions-3.10.0.0:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 >dev-python/urllib3-1.26.6:0 -brotli python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/uvicorn-0.14.0-r1:0 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/websockets-9.1-r1:0 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/wsproto-1.0.0:0 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/zipp-3.5.0:0 -doc python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-python/zope-interface-5.4.0:0 python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-util/cmake-3.21.1:0 -doc -emacs ncurses -qt5 -test -test >dev-util/desktop-file-utils-0.26-r1:0 -emacs >dev-util/glib-utils-2.68.3:0 -python_single_target_python3_8 python_single_target_python3_9 >dev-util/gperf-3.1:0 >dev-util/gtk-doc-am-1.33.2:0 >dev-util/intltool-0.51.0-r2:0 >dev-util/itstool-2.0.6-r1:0 -python_single_target_python3_8 python_single_target_python3_9 >dev-util/meson-0.58.1:0 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -test >dev-util/meson-format-array-0:0 python_targets_python3_8 python_targets_python3_9 >dev-util/ninja-1.10.2-r1:0 -doc -emacs -test -vim-syntax >dev-util/pkgconf-1.8.0:0/3 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 pkg-config -test >dev-util/re2c-2.2:0 -debug -test >dev-vcs/git-2.32.0:0 blksha1 -cgi curl -cvs -doc -emacs -gnome-keyring gpg -highlight iconv -mediawiki -mediawiki-experimental nls pcre -perforce -perl -ppcsha1 -python_single_target_python3_10 -python_single_target_python3_8 python_single_target_python3_9 -subversion -test threads -tk webdav -xinetd >media-fonts/liberation-fonts-2.1.3:0 -fontforge -X -X >media-gfx/graphite2-1.3.14:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -perl -test >media-libs/fontconfig-2.13.1-r2:1.0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -doc -static-libs >media-libs/freetype-2.11.0:2 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 adobe-cff -brotli bzip2 cleartype-hinting -debug -doc -fontforge harfbuzz -infinality png -static-libs -utils -X >media-libs/harfbuzz-2.8.2-r1:0/0.9.18 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 cairo -debug -doc -experimental glib graphite -icu introspection -static-libs -test truetype >media-libs/libpng-1.6.37-r2:0/16 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -apng -cpu_flags_arm_neon cpu_flags_x86_sse -static-libs >net-dns/libidn2-2.3.2:0/2 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -static-libs -verify-sig >net-firewall/iptables-1.8.7:0/1.8.3 -conntrack ipv6 -netlink -nftables -pcap split-usr -static-libs >net-libs/gnutls-3.7.2:0/30 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 cxx -dane -doc -examples -guile idn nls openssl -pkcs11 seccomp -sslv2 -sslv3 -static-libs -test -test-full tls-heartbeat -tools -valgrind >net-libs/libmnl-1.0.4:0/0.2.0 -examples split-usr -static-libs >net-libs/libnsl-1.3.0-r1:0/2 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -static-libs >net-libs/libtirpc-1.3.2:0/3 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 ipv6 -kerberos split-usr -static-libs >net-libs/nghttp2-1.44.0:0/1.14 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -cxx -debug -hpack-tools -jemalloc -static-libs -test threads -utils -xml >net-misc/curl-7.78.0:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -adns -alt-svc -brotli -curl_ssl_gnutls -curl_ssl_mbedtls -curl_ssl_nss curl_ssl_openssl -curl_ssl_winssl ftp -gnutls -gopher -hsts http2 -idn imap ipv6 -kerberos -ldap -mbedtls -nghttp3 -nss openssl pop3 progress-meter -quiche -rtmp -samba smtp -ssh ssl -sslv3 -static-libs -telnet -test tftp -threads -winssl -zstd >net-misc/iputils-20210722:0 arping -caps -clockdiff -doc filecaps -gcrypt -idn ipv6 -nettle nls -rarpd -rdisc ssl -static -tftpd -tracepath -traceroute6 >net-misc/netifrc-0.7.3:0 >net-misc/openssh-8.6_p1-r2:0 -abi_mips_n32 -audit -bindist -debug -hpn -kerberos -ldns -libedit -livecd pam pie scp -sctp -security-key -selinux ssl -static -test -X -X509 -xmss >net-misc/rsync-3.2.3-r4:0 acl -examples iconv ipv6 -lz4 ssl -stunnel -system-zlib xattr -xxhash -zstd >net-misc/wget-1.21.1:0 -cookie_check -debug -gnutls -idn ipv6 -metalink nls -ntlm pcre ssl -static -test -uuid zlib >perl-core/File-Temp-0.231.100:0 >perl-core/Scalar-List-Utils-1.560.0:0 >sys-apps/acl-2.3.1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 nls split-usr -static-libs >sys-apps/attr-2.5.1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -debug nls split-usr -static-libs >sys-apps/baselayout-2.7-r3:0 -build split-usr >sys-apps/busybox-1.33.1:0 -debug ipv6 -livecd -make-symlinks -math -mdev -pam -savedconfig -selinux -sep-usr static -syslog -systemd >sys-apps/coreutils-8.32-r1:0 acl -caps -gmp -hostname -kill -multicall nls -selinux split-usr -static -test -vanilla xattr >sys-apps/dbus-1.12.20-r1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -debug -doc elogind -selinux -static-libs -systemd -test -test -user-session -X >sys-apps/debianutils-4.11.2:0 installkernel -static >sys-apps/diffutils-3.8:0 nls -static >sys-apps/file-5.40-r3:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 bzip2 -lzma -python -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 -seccomp -static-libs zlib >sys-apps/findutils-4.8.0:0 nls -selinux -static -test >sys-apps/gawk-5.1.0:0 -mpfr nls readline >sys-apps/gentoo-functions-0.14:0 >sys-apps/grep-3.6:0 nls pcre -static >sys-apps/groff-1.22.4:0 -examples -uchardet -X >sys-apps/help2man-1.48.3:0 nls >sys-apps/hwids-20210613-r1:0 net pci -systemd udev usb >sys-apps/install-xattr-0.8:0 >sys-apps/iproute2-5.13.0:0 -atm -berkdb -bpf -caps -elf iptables ipv6 -libbsd -minimal -selinux >sys-apps/kbd-2.4.0:0 nls pam -test >sys-apps/kmod-29:0 -debug -doc lzma -pkcs7 -python python_targets_python3_8 python_targets_python3_9 -static-libs tools zlib -zstd >sys-apps/less-590:0 pcre unicode >sys-apps/man-db-2.9.4-r1:0 -berkdb gdbm manpager nls seccomp -selinux -static-libs zlib >sys-apps/man-pages-5.12-r2:0 l10n_de l10n_es l10n_fr l10n_it l10n_ja l10n_nl l10n_pl l10n_pt-BR l10n_ro l10n_ru l10n_zh-CN >sys-apps/man-pages-posix-2017a:0 >sys-apps/net-tools-2.10:0 arp hostname ipv6 -nis nls -plipconfig -selinux -slattach -static >sys-apps/openrc-0.43.3:0 -audit -bash -debug ncurses netifrc -newnet pam -prefix -selinux -sysv-utils unicode >sys-apps/portage-3.0.20-r6:0 -apidoc -build -doc -gentoo-dev ipc native-extensions python_targets_pypy3 -python_targets_python3_10 python_targets_python3_8 python_targets_python3_9 rsync-verify -selinux -test xattr >sys-apps/sandbox-2.24:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 abi_x86_32 abi_x86_64 -abi_x86_x32 >sys-apps/sed-4.8:0 acl nls -selinux -static >sys-apps/shadow-4.9-r1:0 acl -audit -bcrypt -cracklib nls pam -selinux -skey split-usr su xattr >sys-apps/systemd-tmpfiles-249.2:0 -selinux -test >sys-apps/sysvinit-2.99:0 -ibm -selinux -static >sys-apps/texinfo-6.8:0 nls standalone -static >sys-apps/util-linux-2.37.1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -audit -build -caps cramfs -cryptsetup -fdformat -hardlink -kill logger -magic ncurses nls pam -python python_targets_python3_8 python_targets_python3_9 readline -selinux -slang split-usr -static-libs -su suid -systemd -test -tty-helpers -udev unicode >sys-apps/which-2.21:0 >sys-auth/elogind-246.10-r1:0 acl -audit -debug -doc pam policykit -selinux >sys-auth/pambase-20210201.1:0 -caps -debug elogind -gnome-keyring -homed -minimal -mktemp nullok -pam_krb5 -pam_ssh passwdqc -pwhistory -pwquality -securetty -selinux sha512 -systemd >sys-auth/passwdqc-2.0.2-r1:0 >sys-auth/polkit-0.119-r2:0 elogind -examples -gtk introspection -kde nls pam -selinux -systemd -test >sys-devel/autoconf-2.71-r1:2.71 -emacs >sys-devel/autoconf-2.13-r1:2.1 >sys-devel/autoconf-archive-2021.02.19:0 >sys-devel/autoconf-wrapper-15:0 >sys-devel/automake-1.16.4:1.16 -test >sys-devel/automake-wrapper-11:0 >sys-devel/binutils-2.36.1-r2:2.36 -cet -default-gold -doc gold -multitarget nls plugins -static-libs -test -vanilla >sys-devel/binutils-config-5.4:0 native-symlinks >sys-devel/bison-3.7.6:0 -examples nls -static -test >sys-devel/flex-2.6.4-r1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 nls -static -test >sys-devel/gcc-11.2.0:11 -ada -custom-cflags cxx -d -debug -doc -fixed-point fortran -go graphite -hardened -jit -libssp lto multilib nls nptl -objc -objc++ -objc-gc openmp pch -pgo pie sanitize ssp -systemtap -test -valgrind -vanilla -vtv -zstd >sys-devel/gcc-config-2.4:0 cc-wrappers native-symlinks >sys-devel/gettext-0.21-r1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 acl -cvs cxx -doc -emacs -git -java -java ncurses nls openmp -static-libs >sys-devel/gnuconfig-20210107:0 >sys-devel/libtool-2.4.6-r6:2 -vanilla >sys-devel/llvm-12.0.1:12 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -debug -doc -doc -exegesis -gold -libedit libffi -llvm_targets_AArch64 llvm_targets_AMDGPU -llvm_targets_ARC -llvm_targets_ARM -llvm_targets_AVR llvm_targets_BPF -llvm_targets_CSKY -llvm_targets_Hexagon -llvm_targets_Lanai -llvm_targets_Mips -llvm_targets_MSP430 llvm_targets_NVPTX -llvm_targets_PowerPC -llvm_targets_RISCV -llvm_targets_Sparc -llvm_targets_SystemZ -llvm_targets_VE -llvm_targets_WebAssembly llvm_targets_X86 -llvm_targets_XCore ncurses -test -xar -xml -z3 >sys-devel/llvm-common-12.0.1:0 >sys-devel/m4-1.4.19:0 -examples nls >sys-devel/make-4.3:0 -guile nls -static >sys-devel/patch-2.7.6-r4:0 -static -test xattr >sys-fs/e2fsprogs-1.46.3:0 -cron -fuse -lto nls split-usr -static-libs threads >sys-fs/udev-249-r2:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 acl kmod -selinux split-usr -static-libs -test >sys-fs/udev-init-scripts-34:0 >sys-kernel/installkernel-gentoo-3:0 >sys-kernel/linux-headers-5.13:0 -headers-only >sys-libs/binutils-libs-2.36.1-r2:0/2.36.1 -64-bit-bfd -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -cet -multitarget nls -static-libs >sys-libs/e2fsprogs-libs-1.46.3:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 split-usr -static-libs >sys-libs/gdbm-1.20:0/6 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 berkdb nls readline -static-libs >sys-libs/glibc-2.33-r5:2.2 -audit -caps -cet -compile-locales -crypt -custom-cflags -doc -gd -headers-only multiarch multilib -multilib-bootstrap -nscd -profile -selinux ssp static-libs -static-pie -suid -systemd -systemtap -test -vanilla >sys-libs/libcap-2.52:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 pam split-usr -static-libs >sys-libs/libseccomp-2.5.1-r1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -python python_targets_python3_8 python_targets_python3_9 -static-libs >sys-libs/libxcrypt-4.4.23-r2:0/1 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 compat split-usr static-libs system -test >sys-libs/ncurses-6.2_p20210619:0/6 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -ada cxx -debug -doc -gpm -minimal -profile split-usr -static-libs -test tinfo -trace >sys-libs/pam-1.5.1_p20210622:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -audit -berkdb -debug filecaps -nis -selinux split-usr >sys-libs/readline-8.1_p1-r1:0/8 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 split-usr -static-libs unicode -utils >sys-libs/timezone-data-2021a-r1:0 -leaps-timezone nls -zic-slim >sys-libs/zlib-1.2.11-r4:0/1 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 minizip split-usr -static-libs >sys-process/procps-3.3.17-r1:0/8 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 elogind kill -modern-top ncurses nls -selinux split-usr -static-libs -systemd -test unicode >sys-process/psmisc-23.4-r1:0 ipv6 nls -selinux -X >virtual/acl-0-r2:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -static-libs >virtual/awk-1:0 >virtual/dev-manager-0-r2:0 >virtual/editor-0-r3:0 >virtual/libc-1-r1:0 >virtual/libcrypt-2:0/2 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 static-libs >virtual/libelf-3:0/1 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 >virtual/libiconv-0-r2:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 >virtual/libintl-0-r2:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 >virtual/libudev-249:0/1 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -static-libs -systemd >virtual/man-0-r4:0 >virtual/os-headers-0-r2:0 >virtual/package-manager-1:0 >virtual/pager-0:0 >virtual/perl-Carp-1.520.0-r1:0 >virtual/perl-Compress-Raw-Bzip2-2.101.0:0 >virtual/perl-Compress-Raw-Zlib-2.101.0:0 >virtual/perl-CPAN-Meta-2.150.10-r5:0 >virtual/perl-CPAN-Meta-Requirements-2.140.0-r7:0 >virtual/perl-CPAN-Meta-YAML-0.18.0-r7:0 >virtual/perl-Data-Dumper-2.179.0:0 >virtual/perl-Digest-MD5-2.580.0:0 >virtual/perl-Encode-3.80.0:0 >virtual/perl-Exporter-5.760.0:0 >virtual/perl-ExtUtils-CBuilder-0.280.236:0 >virtual/perl-ExtUtils-Install-2.200.0:0 >virtual/perl-ExtUtils-MakeMaker-7.620.0:0 >virtual/perl-ExtUtils-Manifest-1.730.0:0 >virtual/perl-ExtUtils-ParseXS-3.430.0:0 >virtual/perl-File-Spec-3.800.0:0 >virtual/perl-File-Temp-0.231.100:0 >virtual/perl-Getopt-Long-2.520.0:0 >virtual/perl-IO-1.460.0:0 >virtual/perl-IO-Compress-2.102.0:0 >virtual/perl-IO-Socket-IP-0.410.0:0 >virtual/perl-JSON-PP-4.60.0:0 >virtual/perl-libnet-3.130.0:0 ssl >virtual/perl-MIME-Base64-3.160.0:0 >virtual/perl-Module-Metadata-1.0.37-r1:0 >virtual/perl-parent-0.238.0-r1:0 >virtual/perl-Parse-CPAN-Meta-2.150.10-r5:0 >virtual/perl-Perl-OSType-1.10.0-r5:0 >virtual/perl-podlators-4.140.0-r2:0 >virtual/perl-Scalar-List-Utils-1.560.0:0 >virtual/perl-Test-Harness-3.430.0:0 >virtual/perl-Text-ParseWords-3.300.0-r8:0 >virtual/perl-Time-Local-1.300.0:0 >virtual/perl-version-0.992.800:0 >virtual/perl-XSLoader-0.300.0-r4:0 >virtual/pkgconfig-2:0 >virtual/rust-1.54.0:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -rustfmt >virtual/service-manager-1:0 >virtual/ssh-0:0 -minimal >virtual/tmpfiles-0-r1:0 >virtual/ttf-fonts-1-r1:0 >virtual/udev-249:0 >virtual/yacc-0:0 >www-client/pybugz-0.13-r1:0 python_targets_python3_8 python_targets_python3_9 >x11-base/xcb-proto-1.14.1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 python_targets_python3_8 python_targets_python3_9 >x11-base/xorg-proto-2021.4:0 -test >x11-libs/cairo-1.16.0-r4:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -aqua -debug -gles2-only glib -opengl -static-libs svg -utils -valgrind -X >x11-libs/libX11-1.7.2:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -doc ipv6 -test >x11-libs/libXau-1.0.9-r1:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -doc >x11-libs/libxcb-1.14:0/1.12 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -doc -doc -selinux -test xkb >x11-libs/libXdmcp-1.1.3:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -doc >x11-libs/libXext-1.3.4:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -doc >x11-libs/libXrender-0.9.10-r2:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 >x11-libs/pixman-0.40.0:0 -abi_mips_n32 -abi_mips_n64 -abi_mips_o32 -abi_s390_32 -abi_s390_64 -abi_x86_32 abi_x86_64 -abi_x86_x32 -cpu_flags_arm_iwmmxt -cpu_flags_arm_iwmmxt2 -cpu_flags_arm_neon -cpu_flags_ppc_altivec cpu_flags_x86_mmxext cpu_flags_x86_sse2 -cpu_flags_x86_ssse3 -loongson2f -static-libs >x11-libs/xtrans-1.4.0:0 -doc >x11-misc/compose-tables-1.7.2:0 >x11-misc/shared-mime-info-2.1:0 > > >####################### ># build.log # >####################### >>>> Unpacking source... >>>> Unpacking uvicorn-0.14.0.tar.gz to /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work >>>> Source unpacked in /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work >>>> Preparing source in /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0 ... >>>> Source prepared. >>>> Configuring source in /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0 ... >>>> Source configured. >>>> Compiling source in /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0 ... > * python3_8: running distutils-r1_run_phase distutils-r1_python_compile >python3.8 setup.py build -j 24 >running build >running build_py >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn >copying uvicorn/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn >copying uvicorn/__main__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn >copying uvicorn/config.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn >copying uvicorn/importer.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn >copying uvicorn/logging.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn >copying uvicorn/main.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn >copying uvicorn/server.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn >copying uvicorn/subprocess.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn >copying uvicorn/workers.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/_handlers >copying uvicorn/_handlers/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/_handlers >copying uvicorn/_handlers/http.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/_handlers >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/lifespan >copying uvicorn/lifespan/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/lifespan >copying uvicorn/lifespan/off.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/lifespan >copying uvicorn/lifespan/on.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/lifespan >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/loops >copying uvicorn/loops/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/loops >copying uvicorn/loops/asyncio.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/loops >copying uvicorn/loops/auto.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/loops >copying uvicorn/loops/uvloop.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/loops >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/middleware >copying uvicorn/middleware/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/middleware >copying uvicorn/middleware/asgi2.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/middleware >copying uvicorn/middleware/debug.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/middleware >copying uvicorn/middleware/message_logger.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/middleware >copying uvicorn/middleware/proxy_headers.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/middleware >copying uvicorn/middleware/wsgi.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/middleware >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols >copying uvicorn/protocols/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols >copying uvicorn/protocols/utils.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols/http >copying uvicorn/protocols/http/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols/http >copying uvicorn/protocols/http/auto.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols/http >copying uvicorn/protocols/http/flow_control.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols/http >copying uvicorn/protocols/http/h11_impl.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols/http >copying uvicorn/protocols/http/httptools_impl.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols/http >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols/websockets >copying uvicorn/protocols/websockets/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols/websockets >copying uvicorn/protocols/websockets/auto.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols/websockets >copying uvicorn/protocols/websockets/websockets_impl.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols/websockets >copying uvicorn/protocols/websockets/wsproto_impl.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/protocols/websockets >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/supervisors >copying uvicorn/supervisors/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/supervisors >copying uvicorn/supervisors/basereload.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/supervisors >copying uvicorn/supervisors/multiprocess.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/supervisors >copying uvicorn/supervisors/statreload.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/supervisors >copying uvicorn/supervisors/watchgodreload.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_8/lib/uvicorn/supervisors >running egg_info >creating uvicorn.egg-info >writing uvicorn.egg-info/PKG-INFO >writing dependency_links to uvicorn.egg-info/dependency_links.txt >writing entry points to uvicorn.egg-info/entry_points.txt >writing requirements to uvicorn.egg-info/requires.txt >writing top-level names to uvicorn.egg-info/top_level.txt >writing manifest file 'uvicorn.egg-info/SOURCES.txt' >reading manifest file 'uvicorn.egg-info/SOURCES.txt' >reading manifest template 'MANIFEST.in' >warning: no previously-included files matching '__pycache__' found anywhere in distribution >warning: no previously-included files matching '*.py[co]' found anywhere in distribution >adding license file 'LICENSE.md' >writing manifest file 'uvicorn.egg-info/SOURCES.txt' >warning: build_py: byte-compiling is disabled, skipping. > > * python3_9: running distutils-r1_run_phase distutils-r1_python_compile >python3.9 setup.py build -j 24 >running build >running build_py >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn >copying uvicorn/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn >copying uvicorn/__main__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn >copying uvicorn/config.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn >copying uvicorn/importer.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn >copying uvicorn/logging.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn >copying uvicorn/main.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn >copying uvicorn/server.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn >copying uvicorn/subprocess.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn >copying uvicorn/workers.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/_handlers >copying uvicorn/_handlers/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/_handlers >copying uvicorn/_handlers/http.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/_handlers >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/lifespan >copying uvicorn/lifespan/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/lifespan >copying uvicorn/lifespan/off.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/lifespan >copying uvicorn/lifespan/on.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/lifespan >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/loops >copying uvicorn/loops/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/loops >copying uvicorn/loops/asyncio.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/loops >copying uvicorn/loops/auto.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/loops >copying uvicorn/loops/uvloop.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/loops >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/middleware >copying uvicorn/middleware/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/middleware >copying uvicorn/middleware/asgi2.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/middleware >copying uvicorn/middleware/debug.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/middleware >copying uvicorn/middleware/message_logger.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/middleware >copying uvicorn/middleware/proxy_headers.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/middleware >copying uvicorn/middleware/wsgi.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/middleware >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols >copying uvicorn/protocols/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols >copying uvicorn/protocols/utils.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols/http >copying uvicorn/protocols/http/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols/http >copying uvicorn/protocols/http/auto.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols/http >copying uvicorn/protocols/http/flow_control.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols/http >copying uvicorn/protocols/http/h11_impl.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols/http >copying uvicorn/protocols/http/httptools_impl.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols/http >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols/websockets >copying uvicorn/protocols/websockets/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols/websockets >copying uvicorn/protocols/websockets/auto.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols/websockets >copying uvicorn/protocols/websockets/websockets_impl.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols/websockets >copying uvicorn/protocols/websockets/wsproto_impl.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/protocols/websockets >creating /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/supervisors >copying uvicorn/supervisors/__init__.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/supervisors >copying uvicorn/supervisors/basereload.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/supervisors >copying uvicorn/supervisors/multiprocess.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/supervisors >copying uvicorn/supervisors/statreload.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/supervisors >copying uvicorn/supervisors/watchgodreload.py -> /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0-python3_9/lib/uvicorn/supervisors >running egg_info >writing uvicorn.egg-info/PKG-INFO >writing dependency_links to uvicorn.egg-info/dependency_links.txt >writing entry points to uvicorn.egg-info/entry_points.txt >writing requirements to uvicorn.egg-info/requires.txt >writing top-level names to uvicorn.egg-info/top_level.txt >reading manifest file 'uvicorn.egg-info/SOURCES.txt' >reading manifest template 'MANIFEST.in' >warning: no previously-included files matching '__pycache__' found anywhere in distribution >warning: no previously-included files matching '*.py[co]' found anywhere in distribution >adding license file 'LICENSE.md' >writing manifest file 'uvicorn.egg-info/SOURCES.txt' >warning: build_py: byte-compiling is disabled, skipping. > >>>> Source compiled. >>>> Test phase: dev-python/uvicorn-0.14.0-r1 > * python3_8: running distutils-r1_run_phase python_test >python3.8 -m pytest -vv -ra -l -Wdefault >============================= test session starts ============================== >platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3.8 >cachedir: .pytest_cache >rootdir: /var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0, configfile: setup.cfg >plugins: anyio-3.2.1, asyncio-0.15.1, mock-3.6.1 >collecting ... collected 212 items > >tests/test_auto_detection.py::test_loop_auto PASSED [ 0%] >tests/test_auto_detection.py::test_http_auto PASSED [ 0%] >tests/test_auto_detection.py::test_websocket_auto FAILED [ 1%] >tests/test_cli.py::test_cli_headers PASSED [ 1%] >tests/test_config.py::test_debug_app PASSED [ 2%] >tests/test_config.py::test_config_should_reload_is_set[asgi_app-False] PASSED [ 2%] >tests/test_config.py::test_config_should_reload_is_set[tests.test_config:asgi_app-True] PASSED [ 3%] >tests/test_config.py::test_reload_dir_is_set PASSED [ 3%] >tests/test_config.py::test_wsgi_app PASSED [ 4%] >tests/test_config.py::test_proxy_headers PASSED [ 4%] >tests/test_config.py::test_app_unimportable_module PASSED [ 5%] >tests/test_config.py::test_app_unimportable_other PASSED [ 5%] >tests/test_config.py::test_app_factory PASSED [ 6%] >tests/test_config.py::test_concrete_http_class PASSED [ 6%] >tests/test_config.py::test_socket_bind PASSED [ 7%] >tests/test_config.py::test_ssl_config PASSED [ 7%] >tests/test_config.py::test_ssl_config_combined PASSED [ 8%] >tests/test_config.py::test_asgi_version[asgi_app-3.0] PASSED [ 8%] >tests/test_config.py::test_asgi_version[asgi2_app-2.0] PASSED [ 8%] >tests/test_config.py::test_log_config_default[use_colors_not_provided] PASSED [ 9%] >tests/test_config.py::test_log_config_default[use_colors_invalid_value] PASSED [ 9%] >tests/test_config.py::test_log_config_default[use_colors_enabled] PASSED [ 10%] >tests/test_config.py::test_log_config_default[use_colors_disabled] PASSED [ 10%] >tests/test_config.py::test_log_config_json PASSED [ 11%] >tests/test_config.py::test_log_config_yaml[log_config.yml] PASSED [ 11%] >tests/test_config.py::test_log_config_yaml[log_config.yaml] PASSED [ 12%] >tests/test_config.py::test_log_config_file PASSED [ 12%] >tests/test_config.py::test_env_file[0-127.0.0.1] PASSED [ 13%] >tests/test_config.py::test_env_file[0-127.0.0.2] PASSED [ 13%] >tests/test_config.py::test_env_file[1-127.0.0.1] PASSED [ 14%] >tests/test_config.py::test_env_file[1-127.0.0.2] PASSED [ 14%] >tests/test_config.py::test_config_access_log[access log enabled should have single handler] PASSED [ 15%] >tests/test_config.py::test_config_access_log[access log disabled shouldn't have handlers] PASSED [ 15%] >tests/test_config.py::test_config_log_level[5] PASSED [ 16%] >tests/test_config.py::test_config_log_level[10] PASSED [ 16%] >tests/test_config.py::test_config_log_level[20] PASSED [ 16%] >tests/test_config.py::test_config_log_level[30] PASSED [ 17%] >tests/test_config.py::test_config_log_level[40] PASSED [ 17%] >tests/test_config.py::test_config_log_level[50] PASSED [ 18%] >tests/test_config.py::test_ws_max_size PASSED [ 18%] >tests/test_default_headers.py::test_default_default_headers PASSED [ 19%] >tests/test_default_headers.py::test_override_server_header PASSED [ 19%] >tests/test_default_headers.py::test_override_server_header_multiple_times PASSED [ 20%] >tests/test_default_headers.py::test_add_additional_header PASSED [ 20%] >tests/test_lifespan.py::test_lifespan_on PASSED [ 21%] >tests/test_lifespan.py::test_lifespan_off PASSED [ 21%] >tests/test_lifespan.py::test_lifespan_auto PASSED [ 22%] >tests/test_lifespan.py::test_lifespan_auto_with_error PASSED [ 22%] >tests/test_lifespan.py::test_lifespan_on_with_error PASSED [ 23%] >tests/test_lifespan.py::test_lifespan_with_failed_startup[True-auto] PASSED [ 23%] >tests/test_lifespan.py::test_lifespan_with_failed_startup[True-on] PASSED [ 24%] >tests/test_lifespan.py::test_lifespan_with_failed_startup[False-auto] PASSED [ 24%] >tests/test_lifespan.py::test_lifespan_with_failed_startup[False-on] PASSED [ 25%] >tests/test_lifespan.py::test_lifespan_scope_asgi3app PASSED [ 25%] >tests/test_lifespan.py::test_lifespan_scope_asgi2app PASSED [ 25%] >tests/test_lifespan.py::test_lifespan_with_failed_shutdown[True-auto] PASSED [ 26%] >tests/test_lifespan.py::test_lifespan_with_failed_shutdown[True-on] PASSED [ 26%] >tests/test_lifespan.py::test_lifespan_with_failed_shutdown[False-auto] PASSED [ 27%] >tests/test_lifespan.py::test_lifespan_with_failed_shutdown[False-on] PASSED [ 27%] >tests/test_main.py::test_return_close_header PASSED [ 28%] >tests/test_main.py::test_run[default] PASSED [ 28%] >tests/test_main.py::test_run[hostname] PASSED [ 29%] >tests/test_main.py::test_run[ipv6] PASSED [ 29%] >tests/test_main.py::test_run_multiprocess PASSED [ 30%] >tests/test_main.py::test_run_reload PASSED [ 30%] >tests/test_ssl.py::test_run PASSED [ 31%] >tests/test_ssl.py::test_run_chain PASSED [ 31%] >tests/test_ssl.py::test_run_password PASSED [ 32%] >tests/importer/test_importer.py::test_invalid_format PASSED [ 32%] >tests/importer/test_importer.py::test_invalid_module PASSED [ 33%] >tests/importer/test_importer.py::test_invalid_attr PASSED [ 33%] >tests/importer/test_importer.py::test_internal_import_error PASSED [ 33%] >tests/importer/test_importer.py::test_valid_import PASSED [ 34%] >tests/importer/test_importer.py::test_no_import_needed PASSED [ 34%] >tests/middleware/test_debug.py::test_debug_text PASSED [ 35%] >tests/middleware/test_debug.py::test_debug_html PASSED [ 35%] >tests/middleware/test_debug.py::test_debug_after_response_sent PASSED [ 36%] >tests/middleware/test_debug.py::test_debug_not_http PASSED [ 36%] >tests/middleware/test_logging.py::test_trace_logging PASSED [ 37%] >tests/middleware/test_logging.py::test_access_logging[True] PASSED [ 37%] >tests/middleware/test_logging.py::test_access_logging[False] PASSED [ 38%] >tests/middleware/test_logging.py::test_access_logging[None] PASSED [ 38%] >tests/middleware/test_logging.py::test_default_logging[True] PASSED [ 39%] >tests/middleware/test_logging.py::test_default_logging[False] PASSED [ 39%] >tests/middleware/test_logging.py::test_unknown_status_code PASSED [ 40%] >tests/middleware/test_message_logger.py::test_message_logger PASSED [ 40%] >tests/middleware/test_message_logger.py::test_message_logger_exc PASSED [ 41%] >tests/middleware/test_proxy_headers.py::test_proxy_headers_trusted_hosts[*-Remote: https://1.2.3.4:0] PASSED [ 41%] >tests/middleware/test_proxy_headers.py::test_proxy_headers_trusted_hosts[127.0.0.1-Remote: https://1.2.3.4:0] PASSED [ 41%] >tests/middleware/test_proxy_headers.py::test_proxy_headers_trusted_hosts[trusted_hosts2-Remote: https://1.2.3.4:0] PASSED [ 42%] >tests/middleware/test_proxy_headers.py::test_proxy_headers_trusted_hosts[trusted_hosts3-Remote: https://1.2.3.4:0] PASSED [ 42%] >tests/middleware/test_proxy_headers.py::test_proxy_headers_trusted_hosts[127.0.0.1, 10.0.0.1-Remote: https://1.2.3.4:0] PASSED [ 43%] >tests/middleware/test_proxy_headers.py::test_proxy_headers_trusted_hosts[192.168.0.1-Remote: http://127.0.0.1:123] PASSED [ 43%] >tests/middleware/test_proxy_headers.py::test_proxy_headers_multiple_proxies[*-Remote: https://1.2.3.4:0] PASSED [ 44%] >tests/middleware/test_proxy_headers.py::test_proxy_headers_multiple_proxies[trusted_hosts1-Remote: https://1.2.3.4:0] PASSED [ 44%] >tests/middleware/test_proxy_headers.py::test_proxy_headers_multiple_proxies[trusted_hosts2-Remote: https://1.2.3.4:0] PASSED [ 45%] >tests/middleware/test_proxy_headers.py::test_proxy_headers_multiple_proxies[trusted_hosts3-Remote: https://10.0.2.1:0] PASSED [ 45%] >tests/middleware/test_proxy_headers.py::test_proxy_headers_invalid_x_forwarded_for PASSED [ 46%] >tests/middleware/test_wsgi.py::test_wsgi_get PASSED [ 46%] >tests/middleware/test_wsgi.py::test_wsgi_post PASSED [ 47%] >tests/middleware/test_wsgi.py::test_wsgi_exception PASSED [ 47%] >tests/middleware/test_wsgi.py::test_wsgi_exc_info PASSED [ 48%] >tests/middleware/test_wsgi.py::test_build_environ_encoding PASSED [ 48%] >tests/protocols/test_http.py::test_get_request[H11Protocol] PASSED [ 49%] >tests/protocols/test_http.py::test_request_logging[H11Protocol-/] PASSED [ 49%] >tests/protocols/test_http.py::test_request_logging[H11Protocol-/?foo] PASSED [ 50%] >tests/protocols/test_http.py::test_request_logging[H11Protocol-/?foo=bar] PASSED [ 50%] >tests/protocols/test_http.py::test_request_logging[H11Protocol-/?foo=bar&baz=1] PASSED [ 50%] >tests/protocols/test_http.py::test_head_request[H11Protocol] PASSED [ 51%] >tests/protocols/test_http.py::test_post_request[H11Protocol] PASSED [ 51%] >tests/protocols/test_http.py::test_keepalive[H11Protocol] PASSED [ 52%] >tests/protocols/test_http.py::test_keepalive_timeout[H11Protocol] PASSED [ 52%] >tests/protocols/test_http.py::test_close[H11Protocol] PASSED [ 53%] >tests/protocols/test_http.py::test_chunked_encoding[H11Protocol] PASSED [ 53%] >tests/protocols/test_http.py::test_chunked_encoding_empty_body[H11Protocol] PASSED [ 54%] >tests/protocols/test_http.py::test_chunked_encoding_head_request[H11Protocol] PASSED [ 54%] >tests/protocols/test_http.py::test_pipelined_requests[H11Protocol] PASSED [ 55%] >tests/protocols/test_http.py::test_undersized_request[H11Protocol] PASSED [ 55%] >tests/protocols/test_http.py::test_oversized_request[H11Protocol] PASSED [ 56%] >tests/protocols/test_http.py::test_large_post_request[H11Protocol] PASSED [ 56%] >tests/protocols/test_http.py::test_invalid_http[H11Protocol] PASSED [ 57%] >tests/protocols/test_http.py::test_app_exception[H11Protocol] PASSED [ 57%] >tests/protocols/test_http.py::test_exception_during_response[H11Protocol] PASSED [ 58%] >tests/protocols/test_http.py::test_no_response_returned[H11Protocol] PASSED [ 58%] >tests/protocols/test_http.py::test_partial_response_returned[H11Protocol] PASSED [ 58%] >tests/protocols/test_http.py::test_duplicate_start_message[H11Protocol] PASSED [ 59%] >tests/protocols/test_http.py::test_missing_start_message[H11Protocol] PASSED [ 59%] >tests/protocols/test_http.py::test_message_after_body_complete[H11Protocol] PASSED [ 60%] >tests/protocols/test_http.py::test_value_returned[H11Protocol] PASSED [ 60%] >tests/protocols/test_http.py::test_early_disconnect[H11Protocol] PASSED [ 61%] >tests/protocols/test_http.py::test_early_response[H11Protocol] PASSED [ 61%] >tests/protocols/test_http.py::test_read_after_response[H11Protocol] PASSED [ 62%] >tests/protocols/test_http.py::test_http10_request[H11Protocol] PASSED [ 62%] >tests/protocols/test_http.py::test_root_path[H11Protocol] PASSED [ 63%] >tests/protocols/test_http.py::test_raw_path[H11Protocol] PASSED [ 63%] >tests/protocols/test_http.py::test_max_concurrency[H11Protocol] PASSED [ 64%] >tests/protocols/test_http.py::test_shutdown_during_request[H11Protocol] PASSED [ 64%] >tests/protocols/test_http.py::test_shutdown_during_idle[H11Protocol] PASSED [ 65%] >tests/protocols/test_http.py::test_100_continue_sent_when_body_consumed[H11Protocol] PASSED [ 65%] >tests/protocols/test_http.py::test_100_continue_not_sent_when_body_not_consumed[H11Protocol] PASSED [ 66%] >tests/protocols/test_http.py::test_unsupported_upgrade_request[H11Protocol] PASSED [ 66%] >tests/protocols/test_http.py::test_supported_upgrade_request[H11Protocol] PASSED [ 66%] >tests/protocols/test_http.py::test_scopes[H11Protocol-asgi3app-expected_scopes0] PASSED [ 67%] >tests/protocols/test_http.py::test_scopes[H11Protocol-asgi2app-expected_scopes1] PASSED [ 67%] >tests/protocols/test_http.py::test_invalid_http_request[H11Protocol-invalid-method] PASSED [ 68%] >tests/protocols/test_http.py::test_invalid_http_request[H11Protocol-invalid-path] PASSED [ 68%] >tests/protocols/test_http.py::test_invalid_http_request[H11Protocol-invalid-http-version] PASSED [ 69%] >tests/protocols/test_utils.py::test_get_local_addr_with_socket PASSED [ 69%] >tests/protocols/test_utils.py::test_get_remote_addr_with_socket PASSED [ 70%] >tests/protocols/test_utils.py::test_get_local_addr PASSED [ 70%] >tests/protocols/test_utils.py::test_get_remote_addr PASSED [ 71%] >tests/protocols/test_utils.py::test_get_client_addr[ip:port client] PASSED [ 71%] >tests/protocols/test_utils.py::test_get_client_addr[None client] PASSED [ 72%] >tests/protocols/test_websocket.py::test_invalid_upgrade[WSProtocol] PASSED [ 72%] >tests/protocols/test_websocket.py::test_invalid_upgrade[WebSocketProtocol] FAILED [ 73%] >tests/protocols/test_websocket.py::test_accept_connection[WSProtocol] PASSED [ 73%] >tests/protocols/test_websocket.py::test_accept_connection[WebSocketProtocol] FAILED [ 74%] >tests/protocols/test_websocket.py::test_supports_permessage_deflate_extension[WSProtocol] PASSED [ 74%] >tests/protocols/test_websocket.py::test_supports_permessage_deflate_extension[WebSocketProtocol] FAILED [ 75%] >tests/protocols/test_websocket.py::test_close_connection[WSProtocol] PASSED [ 75%] >tests/protocols/test_websocket.py::test_close_connection[WebSocketProtocol] PASSED [ 75%] >tests/protocols/test_websocket.py::test_headers[WSProtocol] PASSED [ 76%] >tests/protocols/test_websocket.py::test_headers[WebSocketProtocol] FAILED [ 76%] >tests/protocols/test_websocket.py::test_path_and_raw_path[WSProtocol] PASSED [ 77%] >tests/protocols/test_websocket.py::test_path_and_raw_path[WebSocketProtocol] FAILED [ 77%] >tests/protocols/test_websocket.py::test_send_text_data_to_client[WSProtocol] PASSED [ 78%] >tests/protocols/test_websocket.py::test_send_text_data_to_client[WebSocketProtocol] FAILED [ 78%] >tests/protocols/test_websocket.py::test_send_binary_data_to_client[WSProtocol] PASSED [ 79%] >tests/protocols/test_websocket.py::test_send_binary_data_to_client[WebSocketProtocol] FAILED [ 79%] >tests/protocols/test_websocket.py::test_send_and_close_connection[WSProtocol] PASSED [ 80%] >tests/protocols/test_websocket.py::test_send_and_close_connection[WebSocketProtocol] FAILED [ 80%] >tests/protocols/test_websocket.py::test_send_text_data_to_server[WSProtocol] PASSED [ 81%] >tests/protocols/test_websocket.py::test_send_text_data_to_server[WebSocketProtocol] FAILED [ 81%] >tests/protocols/test_websocket.py::test_send_binary_data_to_server[WSProtocol] PASSED [ 82%] >tests/protocols/test_websocket.py::test_send_binary_data_to_server[WebSocketProtocol] FAILED [ 82%] >tests/protocols/test_websocket.py::test_send_after_protocol_close[WSProtocol] PASSED [ 83%] >tests/protocols/test_websocket.py::test_send_after_protocol_close[WebSocketProtocol] FAILED [ 83%] >tests/protocols/test_websocket.py::test_missing_handshake[WSProtocol] PASSED [ 83%] >tests/protocols/test_websocket.py::test_missing_handshake[WebSocketProtocol] FAILED [ 84%] >tests/protocols/test_websocket.py::test_send_before_handshake[WSProtocol] PASSED [ 84%] >tests/protocols/test_websocket.py::test_send_before_handshake[WebSocketProtocol] FAILED [ 85%] >tests/protocols/test_websocket.py::test_duplicate_handshake[WSProtocol] PASSED [ 85%] >tests/protocols/test_websocket.py::test_duplicate_handshake[WebSocketProtocol] FAILED [ 86%] >tests/protocols/test_websocket.py::test_asgi_return_value[WSProtocol] PASSED [ 86%] >tests/protocols/test_websocket.py::test_asgi_return_value[WebSocketProtocol] FAILED [ 87%] >tests/protocols/test_websocket.py::test_app_close[None-None-WSProtocol] PASSED [ 87%] >tests/protocols/test_websocket.py::test_app_close[None-None-WebSocketProtocol] FAILED [ 88%] >tests/protocols/test_websocket.py::test_app_close[None-1000-WSProtocol] PASSED [ 88%] >tests/protocols/test_websocket.py::test_app_close[None-1000-WebSocketProtocol] FAILED [ 89%] >tests/protocols/test_websocket.py::test_app_close[None-1001-WSProtocol] PASSED [ 89%] >tests/protocols/test_websocket.py::test_app_close[None-1001-WebSocketProtocol] FAILED [ 90%] >tests/protocols/test_websocket.py::test_app_close[test-None-WSProtocol] PASSED [ 90%] >tests/protocols/test_websocket.py::test_app_close[test-None-WebSocketProtocol] FAILED [ 91%] >tests/protocols/test_websocket.py::test_app_close[test-1000-WSProtocol] PASSED [ 91%] >tests/protocols/test_websocket.py::test_app_close[test-1000-WebSocketProtocol] FAILED [ 91%] >tests/protocols/test_websocket.py::test_app_close[test-1001-WSProtocol] PASSED [ 92%] >tests/protocols/test_websocket.py::test_app_close[test-1001-WebSocketProtocol] FAILED [ 92%] >tests/protocols/test_websocket.py::test_client_close[WSProtocol] PASSED [ 93%] >tests/protocols/test_websocket.py::test_client_close[WebSocketProtocol] FAILED [ 93%] >tests/protocols/test_websocket.py::test_subprotocols[proto1-WSProtocol] PASSED [ 94%] >tests/protocols/test_websocket.py::test_subprotocols[proto1-WebSocketProtocol] FAILED [ 94%] >tests/protocols/test_websocket.py::test_subprotocols[proto2-WSProtocol] PASSED [ 95%] >tests/protocols/test_websocket.py::test_subprotocols[proto2-WebSocketProtocol] FAILED [ 95%] >tests/protocols/test_websocket.py::test_send_binary_data_to_server_bigger_than_default[max=defaults sent=defaults-WebSocketProtocol] FAILED [ 96%] >tests/protocols/test_websocket.py::test_send_binary_data_to_server_bigger_than_default[max=defaults sent=defaults+1-WebSocketProtocol] FAILED [ 96%] >tests/protocols/test_websocket.py::test_send_binary_data_to_server_bigger_than_default[max=10 sent=10-WebSocketProtocol] FAILED [ 97%] >tests/protocols/test_websocket.py::test_send_binary_data_to_server_bigger_than_default[max=10 sent=11-WebSocketProtocol] FAILED [ 97%] >tests/supervisors/test_multiprocess.py::test_multiprocess_run PASSED [ 98%] >tests/supervisors/test_reload.py::TestBaseReload::test_reloader_should_initialize[StatReload] PASSED [ 98%] >tests/supervisors/test_reload.py::TestBaseReload::test_should_reload_when_python_file_is_changed[StatReload] PASSED [ 99%] >tests/supervisors/test_reload.py::TestBaseReload::test_should_not_reload_when_dot_file_is_changed[StatReload] PASSED [ 99%] >tests/supervisors/test_reload.py::TestBaseReload::test_should_reload_when_directories_have_same_prefix[StatReload] PASSED [100%] > >=================================== FAILURES =================================== >_____________________________ test_websocket_auto ______________________________ > > def test_websocket_auto(): > config = Config(app=app) > server_state = ServerState() >> protocol = AutoWebSocketsProtocol(config=config, server_state=server_state) > >config = <uvicorn.config.Config object at 0x7f2bc8324b50> >server_state = <uvicorn.server.ServerState object at 0x7f2bc8324c40> > >tests/test_auto_detection.py:53: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >uvicorn/protocols/websockets/websockets_impl.py:62: in __init__ > super().__init__( > __class__ = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > _loop = None > config = <uvicorn.config.Config object at 0x7f2bc8324b50> > on_connection_lost = None > self = <uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol object at 0x7f2bc8324e20> > server_state = <uvicorn.server.ServerState object at 0x7f2bc8324c40> >/usr/lib/python3.8/site-packages/websockets/legacy/server.py:201: in __init__ > super().__init__(**kwargs) > __class__ = <class 'websockets.legacy.server.WebSocketServerProtocol'> > extensions = [<websockets.extensions.permessage_deflate.ServerPerMessageDeflateFactory object at 0x7f2bc8324cd0>] > extra_headers = None > kwargs = {'max_size': 16777216} > origins = None > process_request = None > select_subprotocol = None > self = <uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol object at 0x7f2bc8324e20> > subprotocols = None > ws_handler = <bound method WebSocketProtocol.ws_handler of <uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol object at 0x7f2bc8324e20>> > ws_server = <uvicorn.protocols.websockets.websockets_impl.Server object at 0x7f2bc8324940> >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol object at 0x7f2bc8324e20> > > def __init__( > self, > *, > ping_interval: Optional[float] = 20, > ping_timeout: Optional[float] = 20, > close_timeout: Optional[float] = None, > max_size: Optional[int] = 2 ** 20, > max_queue: Optional[int] = 2 ** 5, > read_limit: int = 2 ** 16, > write_limit: int = 2 ** 16, > # The following arguments are kept only for backwards compatibility. > host: Optional[str] = None, > port: Optional[int] = None, > secure: Optional[bool] = None, > timeout: Optional[float] = None, > legacy_recv: bool = False, > loop: Optional[asyncio.AbstractEventLoop] = None, > ) -> None: > # Backwards compatibility: close_timeout used to be called timeout. > if timeout is None: > timeout = 10 > else: > warnings.warn("rename timeout to close_timeout", DeprecationWarning) > # If both are specified, timeout is ignored. > if close_timeout is None: > close_timeout = timeout > > self.ping_interval = ping_interval > self.ping_timeout = ping_timeout > self.close_timeout = close_timeout > self.max_size = max_size > self.max_queue = max_queue > self.read_limit = read_limit > self.write_limit = write_limit > >> assert loop is not None >E AssertionError > >close_timeout = 10 >host = None >legacy_recv = False >loop = None >max_queue = 32 >max_size = 16777216 >ping_interval = 20 >ping_timeout = 20 >port = None >read_limit = 65536 >secure = None >self = <uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol object at 0x7f2bc8324e20> >timeout = 10 >write_limit = 65536 > >/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py:135: AssertionError >___________________ test_invalid_upgrade[WebSocketProtocol] ____________________ > > @contextlib.contextmanager > def map_httpcore_exceptions() -> typing.Iterator[None]: > try: >> yield > >from_exc = <class 'httpcore.RemoteProtocolError'> >mapped_exc = <class 'httpx.RemoteProtocolError'> >message = 'Server disconnected without sending a response.' >to_exc = <class 'httpx.RemoteProtocolError'> > >/usr/lib/python3.8/site-packages/httpx/_transports/default.py:61: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <httpx.AsyncHTTPTransport object at 0x7f2bc6da71f0>, method = b'GET' >url = (b'http', b'127.0.0.1', 8000, b'/') >headers = [(b'Host', b'127.0.0.1:8000'), (b'Accept', b'*/*'), (b'Accept-Encoding', b'gzip, deflate'), (b'connection', b'upgrade'), (b'User-Agent', b'python-httpx/0.18.2'), (b'upgrade', b'websocket'), ...] >stream = <httpx.ByteStream object at 0x7f2bc6da7610> >extensions = {'timeout': {'connect': 5, 'pool': 5, 'read': 5, 'write': 5}} > > async def handle_async_request( > self, > method: bytes, > url: typing.Tuple[bytes, bytes, typing.Optional[int], bytes], > headers: typing.List[typing.Tuple[bytes, bytes]], > stream: AsyncByteStream, > extensions: dict, > ) -> typing.Tuple[ > int, typing.List[typing.Tuple[bytes, bytes]], AsyncByteStream, dict > ]: > with map_httpcore_exceptions(): > ( > status_code, > headers, > byte_stream, > extensions, >> ) = await self._pool.handle_async_request( > method=method, > url=url, > headers=headers, > stream=httpcore.AsyncIteratorByteStream(stream.__aiter__()), > extensions=extensions, > ) > >extensions = {'timeout': {'connect': 5, 'pool': 5, 'read': 5, 'write': 5}} >headers = [(b'Host', b'127.0.0.1:8000'), > (b'Accept', b'*/*'), > (b'Accept-Encoding', b'gzip, deflate'), > (b'connection', b'upgrade'), > (b'User-Agent', b'python-httpx/0.18.2'), > (b'upgrade', b'websocket'), > (b'sec-webSocket-version', b'11')] >method = b'GET' >self = <httpx.AsyncHTTPTransport object at 0x7f2bc6da71f0> >stream = <httpx.ByteStream object at 0x7f2bc6da7610> >url = (b'http', b'127.0.0.1', 8000, b'/') > >/usr/lib/python3.8/site-packages/httpx/_transports/default.py:283: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <httpcore.AsyncConnectionPool object at 0x7f2bc6da7070>, method = b'GET' >url = (b'http', b'127.0.0.1', 8000, b'/') >headers = [(b'Host', b'127.0.0.1:8000'), (b'Accept', b'*/*'), (b'Accept-Encoding', b'gzip, deflate'), (b'connection', b'upgrade'), (b'User-Agent', b'python-httpx/0.18.2'), (b'upgrade', b'websocket'), ...] >stream = <httpcore.AsyncIteratorByteStream object at 0x7f2bc6da7910> >extensions = {'timeout': {'connect': 5, 'pool': 5, 'read': 5, 'write': 5}} > > async def handle_async_request( > self, > method: bytes, > url: URL, > headers: Headers, > stream: AsyncByteStream, > extensions: dict, > ) -> Tuple[int, Headers, AsyncByteStream, dict]: > if url[0] not in (b"http", b"https"): > scheme = url[0].decode("latin-1") > host = url[1].decode("latin-1") > if scheme == "": > raise UnsupportedProtocol( > f"The request to '://{host}/' is missing either an 'http://' \ > or 'https://' protocol." > ) > else: > raise UnsupportedProtocol( > f"The request to '{scheme}://{host}' has \ > an unsupported protocol {scheme!r}" > ) > > if not url[1]: > raise LocalProtocolError("Missing hostname in URL.") > > origin = url_to_origin(url) > timeout = cast(TimeoutDict, extensions.get("timeout", {})) > > await self._keepalive_sweep() > > connection: Optional[AsyncHTTPConnection] = None > while connection is None: > async with self._connection_acquiry_lock: > # We get-or-create a connection as an atomic operation, to ensure > # that HTTP/2 requests issued in close concurrency will end up > # on the same connection. > logger.trace("get_connection_from_pool=%r", origin) > connection = await self._get_connection_from_pool(origin) > > if connection is None: > connection = self._create_connection(origin=origin) > logger.trace("created connection=%r", connection) > await self._add_to_pool(connection, timeout=timeout) > else: > logger.trace("reuse connection=%r", connection) > > try: >> response = await connection.handle_async_request( > method, url, headers=headers, stream=stream, extensions=extensions > ) > >connection = <AsyncHTTPConnection [HTTP/1.1, ACTIVE]> >extensions = {'timeout': {'connect': 5, 'pool': 5, 'read': 5, 'write': 5}} >headers = [(b'Host', b'127.0.0.1:8000'), > (b'Accept', b'*/*'), > (b'Accept-Encoding', b'gzip, deflate'), > (b'connection', b'upgrade'), > (b'User-Agent', b'python-httpx/0.18.2'), > (b'upgrade', b'websocket'), > (b'sec-webSocket-version', b'11')] >method = b'GET' >origin = (b'http', b'127.0.0.1', 8000) >self = <httpcore.AsyncConnectionPool object at 0x7f2bc6da7070> >stream = <httpcore.AsyncIteratorByteStream object at 0x7f2bc6da7910> >timeout = {'connect': 5, 'pool': 5, 'read': 5, 'write': 5} >url = (b'http', b'127.0.0.1', 8000, b'/') > >/usr/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:237: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <AsyncHTTPConnection [HTTP/1.1, ACTIVE]>, method = b'GET' >url = (b'http', b'127.0.0.1', 8000, b'/') >headers = [(b'Host', b'127.0.0.1:8000'), (b'Accept', b'*/*'), (b'Accept-Encoding', b'gzip, deflate'), (b'connection', b'upgrade'), (b'User-Agent', b'python-httpx/0.18.2'), (b'upgrade', b'websocket'), ...] >stream = <httpcore.AsyncIteratorByteStream object at 0x7f2bc6da7910> >extensions = {'timeout': {'connect': 5, 'pool': 5, 'read': 5, 'write': 5}} > > async def handle_async_request( > self, > method: bytes, > url: URL, > headers: Headers, > stream: AsyncByteStream, > extensions: dict, > ) -> Tuple[int, Headers, AsyncByteStream, dict]: > assert url_to_origin(url) == self.origin > timeout = cast(TimeoutDict, extensions.get("timeout", {})) > > async with self.request_lock: > if self.connection is None: > if self._connect_failed: > raise NewConnectionRequired() > if not self.socket: > logger.trace( > "open_socket origin=%r timeout=%r", self.origin, timeout > ) > self.socket = await self._open_socket(timeout) > self._create_connection(self.socket) > elif not self.connection.is_available(): > raise NewConnectionRequired() > > assert self.connection is not None > logger.trace( > "connection.handle_async_request method=%r url=%r headers=%r", > method, > url, > headers, > ) >> return await self.connection.handle_async_request( > method, url, headers, stream, extensions > ) > >extensions = {'timeout': {'connect': 5, 'pool': 5, 'read': 5, 'write': 5}} >headers = [(b'Host', b'127.0.0.1:8000'), > (b'Accept', b'*/*'), > (b'Accept-Encoding', b'gzip, deflate'), > (b'connection', b'upgrade'), > (b'User-Agent', b'python-httpx/0.18.2'), > (b'upgrade', b'websocket'), > (b'sec-webSocket-version', b'11')] >method = b'GET' >self = <AsyncHTTPConnection [HTTP/1.1, ACTIVE]> >stream = <httpcore.AsyncIteratorByteStream object at 0x7f2bc6da7910> >timeout = {'connect': 5, 'pool': 5, 'read': 5, 'write': 5} >url = (b'http', b'127.0.0.1', 8000, b'/') > >/usr/lib/python3.8/site-packages/httpcore/_async/connection.py:148: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <AsyncHTTP11Connection [ACTIVE]>, method = b'GET' >url = (b'http', b'127.0.0.1', 8000, b'/') >headers = [(b'Host', b'127.0.0.1:8000'), (b'Accept', b'*/*'), (b'Accept-Encoding', b'gzip, deflate'), (b'connection', b'upgrade'), (b'User-Agent', b'python-httpx/0.18.2'), (b'upgrade', b'websocket'), ...] >stream = <httpcore.AsyncIteratorByteStream object at 0x7f2bc6da7910> >extensions = {'timeout': {'connect': 5, 'pool': 5, 'read': 5, 'write': 5}} > > async def handle_async_request( > self, > method: bytes, > url: URL, > headers: Headers, > stream: AsyncByteStream, > extensions: dict, > ) -> Tuple[int, Headers, AsyncByteStream, dict]: > """ > Send a single HTTP/1.1 request. > > Note that there is no kind of task/thread locking at this layer of interface. > Dealing with locking for concurrency is handled by the `AsyncHTTPConnection`. > """ > timeout = cast(TimeoutDict, extensions.get("timeout", {})) > > if self._state in (ConnectionState.NEW, ConnectionState.IDLE): > self._state = ConnectionState.ACTIVE > self._should_expire_at = None > else: > raise NewConnectionRequired() > > await self._send_request(method, url, headers, timeout) > await self._send_request_body(stream, timeout) > ( > http_version, > status_code, > reason_phrase, > headers, >> ) = await self._receive_response(timeout) > >extensions = {'timeout': {'connect': 5, 'pool': 5, 'read': 5, 'write': 5}} >headers = [(b'Host', b'127.0.0.1:8000'), > (b'Accept', b'*/*'), > (b'Accept-Encoding', b'gzip, deflate'), > (b'connection', b'upgrade'), > (b'User-Agent', b'python-httpx/0.18.2'), > (b'upgrade', b'websocket'), > (b'sec-webSocket-version', b'11')] >method = b'GET' >self = <AsyncHTTP11Connection [ACTIVE]> >stream = <httpcore.AsyncIteratorByteStream object at 0x7f2bc6da7910> >timeout = {'connect': 5, 'pool': 5, 'read': 5, 'write': 5} >url = (b'http', b'127.0.0.1', 8000, b'/') > >/usr/lib/python3.8/site-packages/httpcore/_async/http11.py:128: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <AsyncHTTP11Connection [ACTIVE]> >timeout = {'connect': 5, 'pool': 5, 'read': 5, 'write': 5} > > async def _receive_response( > self, timeout: TimeoutDict > ) -> Tuple[bytes, int, bytes, List[Tuple[bytes, bytes]]]: > """ > Read the response status and headers from the network. > """ > while True: >> event = await self._receive_event(timeout) > >self = <AsyncHTTP11Connection [ACTIVE]> >timeout = {'connect': 5, 'pool': 5, 'read': 5, 'write': 5} > >/usr/lib/python3.8/site-packages/httpcore/_async/http11.py:189: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <AsyncHTTP11Connection [ACTIVE]> >timeout = {'connect': 5, 'pool': 5, 'read': 5, 'write': 5} > > async def _receive_event(self, timeout: TimeoutDict) -> H11Event: > """ > Read a single `h11` event, reading more data from the network if needed. > """ > while True: > with map_exceptions({h11.RemoteProtocolError: RemoteProtocolError}): > event = self._h11_state.next_event() > > if event is h11.NEED_DATA: > data = await self.socket.read(self.READ_NUM_BYTES, timeout) > > # If we feed this case through h11 we'll raise an exception like: > # > # httpcore.RemoteProtocolError: can't handle event type > # ConnectionClosed when role=SERVER and state=SEND_RESPONSE > # > # Which is accurate, but not very informative from an end-user > # perspective. Instead we handle messaging for this case distinctly. > if data == b"" and self._h11_state.their_state == h11.SEND_RESPONSE: > msg = "Server disconnected without sending a response." >> raise RemoteProtocolError(msg) >E httpcore.RemoteProtocolError: Server disconnected without sending a response. > >data = b'' >event = NEED_DATA >msg = 'Server disconnected without sending a response.' >self = <AsyncHTTP11Connection [ACTIVE]> >timeout = {'connect': 5, 'pool': 5, 'read': 5, 'write': 5} > >/usr/lib/python3.8/site-packages/httpcore/_async/http11.py:236: RemoteProtocolError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_invalid_upgrade(protocol_cls): > def app(scope): > return None > > config = Config(app=app, ws=protocol_cls) > async with run_server(config): > async with httpx.AsyncClient() as client: >> response = await client.get( > "http://127.0.0.1:8000", > headers={ > "upgrade": "websocket", > "connection": "upgrade", > "sec-webSocket-version": "11", > }, > timeout=5, > ) > >app = <function test_invalid_upgrade.<locals>.app at 0x7f2bc6d8b3a0> >client = <httpx.AsyncClient object at 0x7f2bc6d9f610> >config = <uvicorn.config.Config object at 0x7f2bc7f4d280> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:55: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >/usr/lib/python3.8/site-packages/httpx/_client.py:1722: in get > return await self.request( > allow_redirects = True > auth = <httpx._client.UseClientDefault object at 0x7f2bc88bd040> > cookies = None > headers = {'connection': 'upgrade', 'sec-webSocket-version': '11', 'upgrade': 'websocket'} > params = None > self = <httpx.AsyncClient object at 0x7f2bc6d9f610> > timeout = 5 > url = 'http://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/httpx/_client.py:1481: in request > response = await self.send( > allow_redirects = True > auth = <httpx._client.UseClientDefault object at 0x7f2bc88bd040> > content = None > cookies = None > data = None > files = None > headers = {'connection': 'upgrade', 'sec-webSocket-version': '11', 'upgrade': 'websocket'} > json = None > method = 'GET' > params = None > request = <Request('GET', 'http://127.0.0.1:8000')> > self = <httpx.AsyncClient object at 0x7f2bc6d9f610> > timeout = 5 > url = 'http://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/httpx/_client.py:1568: in send > response = await self._send_handling_auth( > allow_redirects = True > auth = <httpx.Auth object at 0x7f2bc7eeb5b0> > request = <Request('GET', 'http://127.0.0.1:8000')> > self = <httpx.AsyncClient object at 0x7f2bc6d9f610> > stream = False > timeout = Timeout(timeout=5) >/usr/lib/python3.8/site-packages/httpx/_client.py:1604: in _send_handling_auth > response = await self._send_handling_redirects( > allow_redirects = True > auth = <httpx.Auth object at 0x7f2bc7eeb5b0> > auth_flow = <async_generator object Auth.async_auth_flow at 0x7f2bc6d8bdc0> > history = [] > request = <Request('GET', 'http://127.0.0.1:8000')> > self = <httpx.AsyncClient object at 0x7f2bc6d9f610> > timeout = Timeout(timeout=5) >/usr/lib/python3.8/site-packages/httpx/_client.py:1640: in _send_handling_redirects > response = await self._send_single_request(request, timeout) > allow_redirects = True > history = [] > request = <Request('GET', 'http://127.0.0.1:8000')> > self = <httpx.AsyncClient object at 0x7f2bc6d9f610> > timeout = Timeout(timeout=5) >/usr/lib/python3.8/site-packages/httpx/_client.py:1681: in _send_single_request > ) = await transport.handle_async_request( > request = <Request('GET', 'http://127.0.0.1:8000')> > self = <httpx.AsyncClient object at 0x7f2bc6d9f610> > timeout = Timeout(timeout=5) > timer = <httpx._utils.Timer object at 0x7f2bc7eebdf0> > transport = <httpx.AsyncHTTPTransport object at 0x7f2bc6da71f0> >/usr/lib/python3.8/site-packages/httpx/_transports/default.py:278: in handle_async_request > ( > extensions = {'timeout': {'connect': 5, 'pool': 5, 'read': 5, 'write': 5}} > headers = [(b'Host', b'127.0.0.1:8000'), > (b'Accept', b'*/*'), > (b'Accept-Encoding', b'gzip, deflate'), > (b'connection', b'upgrade'), > (b'User-Agent', b'python-httpx/0.18.2'), > (b'upgrade', b'websocket'), > (b'sec-webSocket-version', b'11')] > method = b'GET' > self = <httpx.AsyncHTTPTransport object at 0x7f2bc6da71f0> > stream = <httpx.ByteStream object at 0x7f2bc6da7610> > url = (b'http', b'127.0.0.1', 8000, b'/') >/usr/lib/python3.8/contextlib.py:131: in __exit__ > self.gen.throw(type, value, traceback) > self = <contextlib._GeneratorContextManager object at 0x7f2bc6da7820> > traceback = <traceback object at 0x7f2bc851d180> > type = <class 'httpcore.RemoteProtocolError'> > value = RemoteProtocolError('Server disconnected without sending a response.') >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > > @contextlib.contextmanager > def map_httpcore_exceptions() -> typing.Iterator[None]: > try: > yield > except Exception as exc: > mapped_exc = None > > for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): > if not isinstance(exc, from_exc): > continue > # We want to map to the most specific exception we can find. > # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to > # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. > if mapped_exc is None or issubclass(to_exc, mapped_exc): > mapped_exc = to_exc > > if mapped_exc is None: # pragma: nocover > raise > > message = str(exc) >> raise mapped_exc(message) from exc >E httpx.RemoteProtocolError: Server disconnected without sending a response. > >from_exc = <class 'httpcore.RemoteProtocolError'> >mapped_exc = <class 'httpx.RemoteProtocolError'> >message = 'Server disconnected without sending a response.' >to_exc = <class 'httpx.RemoteProtocolError'> > >/usr/lib/python3.8/site-packages/httpx/_transports/default.py:78: RemoteProtocolError >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Waiting for application startup. >INFO: ASGI 'lifespan' protocol appears unsupported. >INFO: Application startup complete. >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:on.py:45 Waiting for application startup. >INFO uvicorn.error:on.py:92 ASGI 'lifespan' protocol appears unsupported. >INFO uvicorn.error:on.py:59 Application startup complete. >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc6da7550> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >__________________ test_accept_connection[WebSocketProtocol] ___________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f69190> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f69190> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_accept_connection(protocol_cls): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > > async def open_connection(url): > async with websockets.connect(url) as websocket: > return websocket.open > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> is_open = await open_connection("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_accept_connection.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc6d9f7c0> >open_connection = <function test_accept_connection.<locals>.open_connection at 0x7f2bc6ca90d0> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:93: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:88: in open_connection > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7f71e50> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f69190> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7f71e50> > transport = <_SelectorSocketTransport closed fd=16> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f71dc0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'SnwkvgFGeRN8WFK1gS6odA==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'SnwkvgFGeRN8WFK1gS6odA=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f69190> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f69190> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f69190> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7f18d30> >transport: <_SelectorSocketTransport fd=17 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >________ test_supports_permessage_deflate_extension[WebSocketProtocol] _________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f71d30> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f71d30> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_supports_permessage_deflate_extension(protocol_cls): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > > async def open_connection(url): > extension_factories = [ClientPerMessageDeflateFactory()] > async with websockets.connect(url, extensions=extension_factories) as websocket: > return [extension.name for extension in websocket.extensions] > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> extension_names = await open_connection("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_supports_permessage_deflate_extension.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc7f83d00> >open_connection = <function test_supports_permessage_deflate_extension.<locals>.open_connection at 0x7f2bc6b16f70> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:111: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:106: in open_connection > async with websockets.connect(url, extensions=extension_factories) as websocket: > extension_factories = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f71f70>] > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7f71f10> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f71d30> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7f71f10> > transport = <_SelectorSocketTransport closed fd=16> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f71f70>] > available_subprotocols = None > extensions_header = 'permessage-deflate' > extra_headers = None > key = 'pulkWRtRA6y2ZwGHqRHCPg==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'pulkWRtRA6y2ZwGHqRHCPg=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f71d30> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f71d30> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f71d30> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7f22490> >transport: <_SelectorSocketTransport fd=17 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_______________________ test_headers[WebSocketProtocol] ________________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f206d0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f206d0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_headers(protocol_cls): > class App(WebSocketResponse): > async def websocket_connect(self, message): > headers = self.scope.get("headers") > headers = dict(headers) > assert headers[b"host"].startswith(b"127.0.0.1") > await self.send({"type": "websocket.accept"}) > > async def open_connection(url): > async with websockets.connect(url) as websocket: > return websocket.open > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> is_open = await open_connection("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_headers.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc7f834c0> >open_connection = <function test_headers.<locals>.open_connection at 0x7f2bc6a18940> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:151: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:146: in open_connection > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7f20c40> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f206d0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7f20c40> > transport = <_SelectorSocketTransport closed fd=16> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f20be0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = '7nkEUPSXq0T83xh2PfL+0w==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', '7nkEUPSXq0T83xh2PfL+0w=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f206d0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f206d0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f206d0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7f83250> >transport: <_SelectorSocketTransport fd=17 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >__________________ test_path_and_raw_path[WebSocketProtocol] ___________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a268b0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a268b0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_path_and_raw_path(protocol_cls): > class App(WebSocketResponse): > async def websocket_connect(self, message): > path = self.scope.get("path") > raw_path = self.scope.get("raw_path") > assert path == "/one/two" > assert raw_path == "/one%2Ftwo" > await self.send({"type": "websocket.accept"}) > > async def open_connection(url): > async with websockets.connect(url) as websocket: > return websocket.open > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> is_open = await open_connection("ws://127.0.0.1:8000/one%2Ftwo") > >App = <class 'test_websocket.test_path_and_raw_path.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc6b42f40> >open_connection = <function test_path_and_raw_path.<locals>.open_connection at 0x7f2bc6cecc10> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:172: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:167: in open_connection > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000/one%2Ftwo' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc6a262e0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a268b0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc6a262e0> > transport = <_SelectorSocketTransport closed fd=16> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc6a26a90>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'QG0OC/DwKyFxLCzi24a0wg==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'QG0OC/DwKyFxLCzi24a0wg=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a268b0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/one%2Ftwo', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a268b0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a268b0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc6a6e2e0> >transport: <_SelectorSocketTransport fd=17 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_______________ test_send_text_data_to_client[WebSocketProtocol] _______________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69e9e50> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69e9e50> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_send_text_data_to_client(protocol_cls): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > await self.send({"type": "websocket.send", "text": "123"}) > > async def get_data(url): > async with websockets.connect(url) as websocket: > return await websocket.recv() > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> data = await get_data("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_send_text_data_to_client.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc6a22b50> >get_data = <function test_send_text_data_to_client.<locals>.get_data at 0x7f2bc6a78670> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:190: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:185: in get_data > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc69e9dc0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69e9e50> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc69e9dc0> > transport = <_SelectorSocketTransport closed fd=16> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc69e9cd0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'wAKDER+NqTYI+1kty6nytw==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'wAKDER+NqTYI+1kty6nytw=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69e9e50> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69e9e50> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69e9e50> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc69e9af0> >transport: <_SelectorSocketTransport fd=17 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >______________ test_send_binary_data_to_client[WebSocketProtocol] ______________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a75a30> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a75a30> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_send_binary_data_to_client(protocol_cls): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > await self.send({"type": "websocket.send", "bytes": b"123"}) > > async def get_data(url): > async with websockets.connect(url) as websocket: > return await websocket.recv() > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> data = await get_data("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_send_binary_data_to_client.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc6a75460> >get_data = <function test_send_binary_data_to_client.<locals>.get_data at 0x7f2bc6b27940> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:208: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:203: in get_data > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc6a754f0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a75a30> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc6a754f0> > transport = <_SelectorSocketTransport closed fd=16> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc6a75d60>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = '1NynJqDF5RhMGctZToxviw==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', '1NynJqDF5RhMGctZToxviw=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a75a30> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a75a30> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a75a30> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc6a86370> >transport: <_SelectorSocketTransport fd=17 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >______________ test_send_and_close_connection[WebSocketProtocol] _______________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a0e8e0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a0e8e0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_send_and_close_connection(protocol_cls): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > await self.send({"type": "websocket.send", "text": "123"}) > await self.send({"type": "websocket.close"}) > > async def get_data(url): > async with websockets.connect(url) as websocket: > data = await websocket.recv() > is_open = True > try: > await websocket.recv() > except Exception: > is_open = False > return (data, is_open) > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> (data, is_open) = await get_data("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_send_and_close_connection.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc7f225b0> >get_data = <function test_send_and_close_connection.<locals>.get_data at 0x7f2bc6afd280> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:233: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:222: in get_data > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc6a0e040> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a0e8e0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc6a0e040> > transport = <_SelectorSocketTransport closed fd=16> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc6a0e370>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'SABoK3QYrt/TjCm65JGVhQ==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'SABoK3QYrt/TjCm65JGVhQ=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a0e8e0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a0e8e0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a0e8e0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc69e9430> >transport: <_SelectorSocketTransport fd=17 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_______________ test_send_text_data_to_server[WebSocketProtocol] _______________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f79eb0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f79eb0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_send_text_data_to_server(protocol_cls): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > > async def websocket_receive(self, message): > _text = message.get("text") > await self.send({"type": "websocket.send", "text": _text}) > > async def send_text(url): > async with websockets.connect(url) as websocket: > await websocket.send("abc") > return await websocket.recv() > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> data = await send_text("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_send_text_data_to_server.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc7f7c9d0> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >send_text = <function test_send_text_data_to_server.<locals>.send_text at 0x7f2bc6a91b80> > >tests/protocols/test_websocket.py:256: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:250: in send_text > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7f798b0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f79eb0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7f798b0> > transport = <_SelectorSocketTransport closed fd=16> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f79ac0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'WEeCs1hjKDYrwvshtVYP5w==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'WEeCs1hjKDYrwvshtVYP5w=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f79eb0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f79eb0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f79eb0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7f79b80> >transport: <_SelectorSocketTransport fd=17 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >______________ test_send_binary_data_to_server[WebSocketProtocol] ______________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f426a0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f426a0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_send_binary_data_to_server(protocol_cls): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > > async def websocket_receive(self, message): > _bytes = message.get("bytes") > await self.send({"type": "websocket.send", "bytes": _bytes}) > > async def send_text(url): > async with websockets.connect(url) as websocket: > await websocket.send(b"abc") > return await websocket.recv() > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> data = await send_text("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_send_binary_data_to_server.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc8324c40> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >send_text = <function test_send_binary_data_to_server.<locals>.send_text at 0x7f2bc6b58310> > >tests/protocols/test_websocket.py:278: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:272: in send_text > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7f42b20> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f426a0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7f42b20> > transport = <_SelectorSocketTransport closed fd=16> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f42cd0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'PAmDvlGl0UFfvcfk4FN8mg==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'PAmDvlGl0UFfvcfk4FN8mg=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f426a0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f426a0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f426a0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7eddc70> >transport: <_SelectorSocketTransport fd=17 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >______________ test_send_after_protocol_close[WebSocketProtocol] _______________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a223a0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a223a0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=16>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_send_after_protocol_close(protocol_cls): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > await self.send({"type": "websocket.send", "text": "123"}) > await self.send({"type": "websocket.close"}) > with pytest.raises(Exception): > await self.send({"type": "websocket.send", "text": "123"}) > > async def get_data(url): > async with websockets.connect(url) as websocket: > data = await websocket.recv() > is_open = True > try: > await websocket.recv() > except Exception: > is_open = False > return (data, is_open) > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> (data, is_open) = await get_data("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_send_after_protocol_close.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc6a7d850> >get_data = <function test_send_after_protocol_close.<locals>.get_data at 0x7f2bc6a14820> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:305: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:294: in get_data > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc6a224c0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a223a0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc6a224c0> > transport = <_SelectorSocketTransport closed fd=16> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc6a225b0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'zjW8bNdPTkbKKkK+fdbpEQ==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'zjW8bNdPTkbKKkK+fdbpEQ=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a223a0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a223a0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a223a0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc6a226d0> >transport: <_SelectorSocketTransport fd=17 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >__________________ test_missing_handshake[WebSocketProtocol] ___________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f428e0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f428e0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_missing_handshake(protocol_cls): > async def app(app, receive, send): > pass > > async def connect(url): > await websockets.connect(url) > > config = Config(app=app, ws=protocol_cls, lifespan="off") > async with run_server(config): > with pytest.raises(websockets.exceptions.InvalidStatusCode) as exc_info: >> await connect("ws://127.0.0.1:8000") > >app = <function test_missing_handshake.<locals>.app at 0x7f2bc6b58550> >config = <uvicorn.config.Config object at 0x7f2bc6be9370> >connect = <function test_missing_handshake.<locals>.connect at 0x7f2bc6a18dc0> >exc_info = <ExceptionInfo for raises contextmanager> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:322: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:317: in connect > await websockets.connect(url) > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f428e0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7f425e0> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f421c0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'ifsQ6sZ6fFRxHea1Vp0MyQ==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'ifsQ6sZ6fFRxHea1Vp0MyQ=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f428e0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f428e0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f428e0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7f422b0> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >________________ test_send_before_handshake[WebSocketProtocol] _________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f62a00> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f62a00> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_send_before_handshake(protocol_cls): > async def app(scope, receive, send): > await send({"type": "websocket.send", "text": "123"}) > > async def connect(url): > await websockets.connect(url) > > config = Config(app=app, ws=protocol_cls, lifespan="off") > async with run_server(config): > with pytest.raises(websockets.exceptions.InvalidStatusCode) as exc_info: >> await connect("ws://127.0.0.1:8000") > >app = <function test_send_before_handshake.<locals>.app at 0x7f2bc6a14670> >config = <uvicorn.config.Config object at 0x7f2bc6a22eb0> >connect = <function test_send_before_handshake.<locals>.connect at 0x7f2bc6d1bdc0> >exc_info = <ExceptionInfo for raises contextmanager> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:338: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:333: in connect > await websockets.connect(url) > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f62a00> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc6bfe160> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc6bfe220>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'owKPyuQdaZd8fV3MWXea2w==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'owKPyuQdaZd8fV3MWXea2w=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f62a00> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f62a00> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f62a00> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc6bfe970> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_________________ test_duplicate_handshake[WebSocketProtocol] __________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6bfc220> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6bfc220> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_duplicate_handshake(protocol_cls): > async def app(scope, receive, send): > await send({"type": "websocket.accept"}) > await send({"type": "websocket.accept"}) > > async def connect(url): > async with websockets.connect(url) as websocket: > _ = await websocket.recv() > > config = Config(app=app, ws=protocol_cls, lifespan="off") > async with run_server(config): > with pytest.raises(websockets.exceptions.ConnectionClosed) as exc_info: >> await connect("ws://127.0.0.1:8000") > >app = <function test_duplicate_handshake.<locals>.app at 0x7f2bc6d1b1f0> >config = <uvicorn.config.Config object at 0x7f2bc6b5a610> >connect = <function test_duplicate_handshake.<locals>.connect at 0x7f2bc69eb4c0> >exc_info = <ExceptionInfo for raises contextmanager> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:356: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:350: in connect > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc6bfc0a0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6bfc220> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc6bfc0a0> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc6bfcfd0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'qjEyd36XWoL4v338PR+trA==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'qjEyd36XWoL4v338PR+trA=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6bfc220> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6bfc220> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6bfc220> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc6bfceb0> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >__________________ test_asgi_return_value[WebSocketProtocol] ___________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6c02160> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6c02160> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_asgi_return_value(protocol_cls): > """ > The ASGI callable should return 'None'. If it doesn't make sure that > the connection is closed with an error condition. > """ > > async def app(scope, receive, send): > await send({"type": "websocket.accept"}) > return 123 > > async def connect(url): > async with websockets.connect(url) as websocket: > _ = await websocket.recv() > > config = Config(app=app, ws=protocol_cls, lifespan="off") > async with run_server(config): > with pytest.raises(websockets.exceptions.ConnectionClosed) as exc_info: >> await connect("ws://127.0.0.1:8000") > >app = <function test_asgi_return_value.<locals>.app at 0x7f2bc6ce5820> >config = <uvicorn.config.Config object at 0x7f2bc6bfe970> >connect = <function test_asgi_return_value.<locals>.connect at 0x7f2bc6ce5a60> >exc_info = <ExceptionInfo for raises contextmanager> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > >tests/protocols/test_websocket.py:379: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:373: in connect > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc6c024f0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6c02160> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc6c024f0> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc6c02820>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'lStq0DVYtuvKSXN0BzLGyA==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'lStq0DVYtuvKSXN0BzLGyA=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6c02160> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6c02160> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6c02160> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7f2c250> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_________________ test_app_close[None-None-WebSocketProtocol] __________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d790> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d790> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >code = None, reason = None > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > @pytest.mark.parametrize("code", [None, 1000, 1001]) > @pytest.mark.parametrize("reason", [None, "test"]) > async def test_app_close(protocol_cls, code, reason): > async def app(scope, receive, send): > while True: > message = await receive() > if message["type"] == "websocket.connect": > await send({"type": "websocket.accept"}) > elif message["type"] == "websocket.receive": > reply = {"type": "websocket.close"} > > if code is not None: > reply["code"] = code > > if reason is not None: > reply["reason"] = reason > > await send(reply) > elif message["type"] == "websocket.disconnect": > break > > async def websocket_session(url): > async with websockets.connect(url) as websocket: > await websocket.ping() > await websocket.send("abc") > await websocket.recv() > > config = Config(app=app, ws=protocol_cls, lifespan="off") > async with run_server(config): > with pytest.raises(websockets.exceptions.ConnectionClosed) as exc_info: >> await websocket_session("ws://127.0.0.1:8000") > >app = <function test_app_close.<locals>.app at 0x7f2bc6ce51f0> >code = None >config = <uvicorn.config.Config object at 0x7f2bc7e9fbe0> >exc_info = <ExceptionInfo for raises contextmanager> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >reason = None >websocket_session = <function test_app_close.<locals>.websocket_session at 0x7f2bc6a9e430> > >tests/protocols/test_websocket.py:415: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:407: in websocket_session > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7f5d160> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d790> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7f5d160> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f5d7f0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = '7TEw+ejC+0ZUpdERFMhx0g==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', '7TEw+ejC+0ZUpdERFMhx0g=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d790> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d790> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d790> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7eb0430> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_________________ test_app_close[None-1000-WebSocketProtocol] __________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f20070> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f20070> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >code = 1000, reason = None > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > @pytest.mark.parametrize("code", [None, 1000, 1001]) > @pytest.mark.parametrize("reason", [None, "test"]) > async def test_app_close(protocol_cls, code, reason): > async def app(scope, receive, send): > while True: > message = await receive() > if message["type"] == "websocket.connect": > await send({"type": "websocket.accept"}) > elif message["type"] == "websocket.receive": > reply = {"type": "websocket.close"} > > if code is not None: > reply["code"] = code > > if reason is not None: > reply["reason"] = reason > > await send(reply) > elif message["type"] == "websocket.disconnect": > break > > async def websocket_session(url): > async with websockets.connect(url) as websocket: > await websocket.ping() > await websocket.send("abc") > await websocket.recv() > > config = Config(app=app, ws=protocol_cls, lifespan="off") > async with run_server(config): > with pytest.raises(websockets.exceptions.ConnectionClosed) as exc_info: >> await websocket_session("ws://127.0.0.1:8000") > >app = <function test_app_close.<locals>.app at 0x7f2bc6cc0040> >code = 1000 >config = <uvicorn.config.Config object at 0x7f2bc6cd9070> >exc_info = <ExceptionInfo for raises contextmanager> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >reason = None >websocket_session = <function test_app_close.<locals>.websocket_session at 0x7f2bc6cc0af0> > >tests/protocols/test_websocket.py:415: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:407: in websocket_session > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7f20e50> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f20070> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7f20e50> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f20190>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'CoFhJkOheogEllTiXxxWwQ==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'CoFhJkOheogEllTiXxxWwQ=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f20070> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f20070> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f20070> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7ed5e20> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_________________ test_app_close[None-1001-WebSocketProtocol] __________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25130> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25130> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >code = 1001, reason = None > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > @pytest.mark.parametrize("code", [None, 1000, 1001]) > @pytest.mark.parametrize("reason", [None, "test"]) > async def test_app_close(protocol_cls, code, reason): > async def app(scope, receive, send): > while True: > message = await receive() > if message["type"] == "websocket.connect": > await send({"type": "websocket.accept"}) > elif message["type"] == "websocket.receive": > reply = {"type": "websocket.close"} > > if code is not None: > reply["code"] = code > > if reason is not None: > reply["reason"] = reason > > await send(reply) > elif message["type"] == "websocket.disconnect": > break > > async def websocket_session(url): > async with websockets.connect(url) as websocket: > await websocket.ping() > await websocket.send("abc") > await websocket.recv() > > config = Config(app=app, ws=protocol_cls, lifespan="off") > async with run_server(config): > with pytest.raises(websockets.exceptions.ConnectionClosed) as exc_info: >> await websocket_session("ws://127.0.0.1:8000") > >app = <function test_app_close.<locals>.app at 0x7f2bc6c7aee0> >code = 1001 >config = <uvicorn.config.Config object at 0x7f2bc7f25790> >exc_info = <ExceptionInfo for raises contextmanager> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >reason = None >websocket_session = <function test_app_close.<locals>.websocket_session at 0x7f2bc6abc040> > >tests/protocols/test_websocket.py:415: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:407: in websocket_session > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7f256a0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25130> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7f256a0> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f25d60>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'SVjWRXLtO/3Q2fCaH+PN8A==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'SVjWRXLtO/3Q2fCaH+PN8A=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25130> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25130> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25130> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7ef8880> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_________________ test_app_close[test-None-WebSocketProtocol] __________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6b24eb0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6b24eb0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >code = None, reason = 'test' > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > @pytest.mark.parametrize("code", [None, 1000, 1001]) > @pytest.mark.parametrize("reason", [None, "test"]) > async def test_app_close(protocol_cls, code, reason): > async def app(scope, receive, send): > while True: > message = await receive() > if message["type"] == "websocket.connect": > await send({"type": "websocket.accept"}) > elif message["type"] == "websocket.receive": > reply = {"type": "websocket.close"} > > if code is not None: > reply["code"] = code > > if reason is not None: > reply["reason"] = reason > > await send(reply) > elif message["type"] == "websocket.disconnect": > break > > async def websocket_session(url): > async with websockets.connect(url) as websocket: > await websocket.ping() > await websocket.send("abc") > await websocket.recv() > > config = Config(app=app, ws=protocol_cls, lifespan="off") > async with run_server(config): > with pytest.raises(websockets.exceptions.ConnectionClosed) as exc_info: >> await websocket_session("ws://127.0.0.1:8000") > >app = <function test_app_close.<locals>.app at 0x7f2bc6abcd30> >code = None >config = <uvicorn.config.Config object at 0x7f2bc6b249d0> >exc_info = <ExceptionInfo for raises contextmanager> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >reason = 'test' >websocket_session = <function test_app_close.<locals>.websocket_session at 0x7f2bc69d78b0> > >tests/protocols/test_websocket.py:415: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:407: in websocket_session > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7eb0190> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6b24eb0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7eb0190> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7eb0d00>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'RoTgZLtM1fSOV6/WK0GJ0A==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'RoTgZLtM1fSOV6/WK0GJ0A=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6b24eb0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6b24eb0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6b24eb0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7f715b0> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_________________ test_app_close[test-1000-WebSocketProtocol] __________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a64e50> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a64e50> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >code = 1000, reason = 'test' > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > @pytest.mark.parametrize("code", [None, 1000, 1001]) > @pytest.mark.parametrize("reason", [None, "test"]) > async def test_app_close(protocol_cls, code, reason): > async def app(scope, receive, send): > while True: > message = await receive() > if message["type"] == "websocket.connect": > await send({"type": "websocket.accept"}) > elif message["type"] == "websocket.receive": > reply = {"type": "websocket.close"} > > if code is not None: > reply["code"] = code > > if reason is not None: > reply["reason"] = reason > > await send(reply) > elif message["type"] == "websocket.disconnect": > break > > async def websocket_session(url): > async with websockets.connect(url) as websocket: > await websocket.ping() > await websocket.send("abc") > await websocket.recv() > > config = Config(app=app, ws=protocol_cls, lifespan="off") > async with run_server(config): > with pytest.raises(websockets.exceptions.ConnectionClosed) as exc_info: >> await websocket_session("ws://127.0.0.1:8000") > >app = <function test_app_close.<locals>.app at 0x7f2bc6ccca60> >code = 1000 >config = <uvicorn.config.Config object at 0x7f2bc6a71ee0> >exc_info = <ExceptionInfo for raises contextmanager> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >reason = 'test' >websocket_session = <function test_app_close.<locals>.websocket_session at 0x7f2bc6cccf70> > >tests/protocols/test_websocket.py:415: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:407: in websocket_session > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc6a642e0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a64e50> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc6a642e0> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc6a64ac0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'YIla0qS/edSYXyjaCBvA8Q==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'YIla0qS/edSYXyjaCBvA8Q=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a64e50> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a64e50> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a64e50> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7eeb310> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_________________ test_app_close[test-1001-WebSocketProtocol] __________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7ed21f0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7ed21f0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >code = 1001, reason = 'test' > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > @pytest.mark.parametrize("code", [None, 1000, 1001]) > @pytest.mark.parametrize("reason", [None, "test"]) > async def test_app_close(protocol_cls, code, reason): > async def app(scope, receive, send): > while True: > message = await receive() > if message["type"] == "websocket.connect": > await send({"type": "websocket.accept"}) > elif message["type"] == "websocket.receive": > reply = {"type": "websocket.close"} > > if code is not None: > reply["code"] = code > > if reason is not None: > reply["reason"] = reason > > await send(reply) > elif message["type"] == "websocket.disconnect": > break > > async def websocket_session(url): > async with websockets.connect(url) as websocket: > await websocket.ping() > await websocket.send("abc") > await websocket.recv() > > config = Config(app=app, ws=protocol_cls, lifespan="off") > async with run_server(config): > with pytest.raises(websockets.exceptions.ConnectionClosed) as exc_info: >> await websocket_session("ws://127.0.0.1:8000") > >app = <function test_app_close.<locals>.app at 0x7f2bc6d14040> >code = 1001 >config = <uvicorn.config.Config object at 0x7f2bc6b14c10> >exc_info = <ExceptionInfo for raises contextmanager> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >reason = 'test' >websocket_session = <function test_app_close.<locals>.websocket_session at 0x7f2bc6d1bee0> > >tests/protocols/test_websocket.py:415: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:407: in websocket_session > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7ed2550> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7ed21f0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7ed2550> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7ed20d0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = '0ME0Fhp7YThXDX9y6naSPQ==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', '0ME0Fhp7YThXDX9y6naSPQ=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7ed21f0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7ed21f0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7ed21f0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc6a070d0> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_____________________ test_client_close[WebSocketProtocol] _____________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6d9ffd0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6d9ffd0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > async def test_client_close(protocol_cls): > async def app(scope, receive, send): > while True: > message = await receive() > if message["type"] == "websocket.connect": > await send({"type": "websocket.accept"}) > elif message["type"] == "websocket.receive": > pass > elif message["type"] == "websocket.disconnect": > break > > async def websocket_session(url): > async with websockets.connect(url) as websocket: > await websocket.ping() > await websocket.send("abc") > > config = Config(app=app, ws=protocol_cls, lifespan="off") > async with run_server(config): >> await websocket_session("ws://127.0.0.1:8000") > >app = <function test_client_close.<locals>.app at 0x7f2bc6a09a60> >config = <uvicorn.config.Config object at 0x7f2bc7f4d9a0> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >websocket_session = <function test_client_close.<locals>.websocket_session at 0x7f2bc6a09d30> > >tests/protocols/test_websocket.py:440: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:434: in websocket_session > async with websockets.connect(url) as websocket: > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc69f9520> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6d9ffd0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc69f9520> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc69f9640>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'Mt1pkEVcBVRmK5+eoXYbvg==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'Mt1pkEVcBVRmK5+eoXYbvg=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6d9ffd0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6d9ffd0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6d9ffd0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc69f93d0> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_________________ test_subprotocols[proto1-WebSocketProtocol] __________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69dd3d0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69dd3d0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >subprotocol = 'proto1' > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > @pytest.mark.parametrize("subprotocol", ["proto1", "proto2"]) > async def test_subprotocols(protocol_cls, subprotocol): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept", "subprotocol": subprotocol}) > > async def get_subprotocol(url): > async with websockets.connect( > url, subprotocols=["proto1", "proto2"] > ) as websocket: > return websocket.subprotocol > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> accepted_subprotocol = await get_subprotocol("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_subprotocols.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc6b356a0> >get_subprotocol = <function test_subprotocols.<locals>.get_subprotocol at 0x7f2bc6a25310> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >subprotocol = 'proto1' > >tests/protocols/test_websocket.py:459: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:452: in get_subprotocol > async with websockets.connect( > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc69dd730> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69dd3d0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc69dd730> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc69ddaf0>] > available_subprotocols = ['proto1', 'proto2'] > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = '8Sh1mT5FZM0d14L01/hwHw==' > origin = None > protocol_header = 'proto1, proto2' > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', '8Sh1mT5FZM0d14L01/hwHw=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('Sec-WebSocket-Protocol', 'proto1, proto2'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69dd3d0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69dd3d0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc69dd3d0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc69dd9a0> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_________________ test_subprotocols[proto2-WebSocketProtocol] __________________ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d1f0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d1f0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >subprotocol = 'proto2' > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", WS_PROTOCOLS) > @pytest.mark.parametrize("subprotocol", ["proto1", "proto2"]) > async def test_subprotocols(protocol_cls, subprotocol): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept", "subprotocol": subprotocol}) > > async def get_subprotocol(url): > async with websockets.connect( > url, subprotocols=["proto1", "proto2"] > ) as websocket: > return websocket.subprotocol > > config = Config(app=App, ws=protocol_cls, lifespan="off") > async with run_server(config): >> accepted_subprotocol = await get_subprotocol("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_subprotocols.<locals>.App'> >config = <uvicorn.config.Config object at 0x7f2bc6a46190> >get_subprotocol = <function test_subprotocols.<locals>.get_subprotocol at 0x7f2bc6c394c0> >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >subprotocol = 'proto2' > >tests/protocols/test_websocket.py:459: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:452: in get_subprotocol > async with websockets.connect( > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7f5d2e0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d1f0> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7f5d2e0> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f5d340>] > available_subprotocols = ['proto1', 'proto2'] > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'dY3Lm4VZBQx2Yv5WAwyeRA==' > origin = None > protocol_header = 'proto1, proto2' > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'dY3Lm4VZBQx2Yv5WAwyeRA=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('Sec-WebSocket-Protocol', 'proto1, proto2'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d1f0> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d1f0> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f5d1f0> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc69d36d0> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_ test_send_binary_data_to_server_bigger_than_default[max=defaults sent=defaults-WebSocketProtocol] _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6aa3730> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6aa3730> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >client_size_sent = 16777216, server_size_max = 16777216, expected_result = 0 > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", ONLY_WEBSOCKETPROTOCOL) > @pytest.mark.parametrize( > "client_size_sent, server_size_max, expected_result", > [ > (MAX_WS_BYTES, MAX_WS_BYTES, 0), > (MAX_WS_BYTES_PLUS1, MAX_WS_BYTES, 1009), > (10, 10, 0), > (11, 10, 1009), > ], > ids=[ > "max=defaults sent=defaults", > "max=defaults sent=defaults+1", > "max=10 sent=10", > "max=10 sent=11", > ], > ) > async def test_send_binary_data_to_server_bigger_than_default( > protocol_cls, client_size_sent, server_size_max, expected_result > ): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > > async def websocket_receive(self, message): > _bytes = message.get("bytes") > await self.send({"type": "websocket.send", "bytes": _bytes}) > > async def send_text(url): > async with websockets.connect(url, max_size=client_size_sent) as websocket: > await websocket.send(b"\x01" * client_size_sent) > return await websocket.recv() > > config = Config( > app=App, ws=protocol_cls, lifespan="off", ws_max_size=server_size_max > ) > async with run_server(config): > if expected_result == 0: >> data = await send_text("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_send_binary_data_to_server_bigger_than_default.<locals>.App'> >client_size_sent = 16777216 >config = <uvicorn.config.Config object at 0x7f2bc7eb0190> >expected_result = 0 >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >send_text = <function test_send_binary_data_to_server_bigger_than_default.<locals>.send_text at 0x7f2bc6c44040> >server_size_max = 16777216 > >tests/protocols/test_websocket.py:505: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:496: in send_text > async with websockets.connect(url, max_size=client_size_sent) as websocket: > client_size_sent = 16777216 > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc6aa33d0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6aa3730> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc6aa33d0> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc6aa3eb0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'Zy5lLUFa011Wdv4aTCywCw==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'Zy5lLUFa011Wdv4aTCywCw=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6aa3730> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6aa3730> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6aa3730> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc6a07e80> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_ test_send_binary_data_to_server_bigger_than_default[max=defaults sent=defaults+1-WebSocketProtocol] _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25c70> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25c70> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >client_size_sent = 16777217, server_size_max = 16777216, expected_result = 1009 > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", ONLY_WEBSOCKETPROTOCOL) > @pytest.mark.parametrize( > "client_size_sent, server_size_max, expected_result", > [ > (MAX_WS_BYTES, MAX_WS_BYTES, 0), > (MAX_WS_BYTES_PLUS1, MAX_WS_BYTES, 1009), > (10, 10, 0), > (11, 10, 1009), > ], > ids=[ > "max=defaults sent=defaults", > "max=defaults sent=defaults+1", > "max=10 sent=10", > "max=10 sent=11", > ], > ) > async def test_send_binary_data_to_server_bigger_than_default( > protocol_cls, client_size_sent, server_size_max, expected_result > ): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > > async def websocket_receive(self, message): > _bytes = message.get("bytes") > await self.send({"type": "websocket.send", "bytes": _bytes}) > > async def send_text(url): > async with websockets.connect(url, max_size=client_size_sent) as websocket: > await websocket.send(b"\x01" * client_size_sent) > return await websocket.recv() > > config = Config( > app=App, ws=protocol_cls, lifespan="off", ws_max_size=server_size_max > ) > async with run_server(config): > if expected_result == 0: > data = await send_text("ws://127.0.0.1:8000") > assert data == b"\x01" * client_size_sent > else: > with pytest.raises(websockets.ConnectionClosedError) as e: >> data = await send_text("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_send_binary_data_to_server_bigger_than_default.<locals>.App'> >client_size_sent = 16777217 >config = <uvicorn.config.Config object at 0x7f2bc7f627c0> >e = <ExceptionInfo for raises contextmanager> >expected_result = 1009 >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >send_text = <function test_send_binary_data_to_server_bigger_than_default.<locals>.send_text at 0x7f2bc69cc0d0> >server_size_max = 16777216 > >tests/protocols/test_websocket.py:509: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:496: in send_text > async with websockets.connect(url, max_size=client_size_sent) as websocket: > client_size_sent = 16777217 > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7f25d30> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25c70> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7f25d30> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7f25fa0>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'M1Szv5WWSHmvCdahFH//Vg==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'M1Szv5WWSHmvCdahFH//Vg=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25c70> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25c70> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7f25c70> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc7f25040> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_ test_send_binary_data_to_server_bigger_than_default[max=10 sent=10-WebSocketProtocol] _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7fbba00> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7fbba00> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >client_size_sent = 10, server_size_max = 10, expected_result = 0 > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", ONLY_WEBSOCKETPROTOCOL) > @pytest.mark.parametrize( > "client_size_sent, server_size_max, expected_result", > [ > (MAX_WS_BYTES, MAX_WS_BYTES, 0), > (MAX_WS_BYTES_PLUS1, MAX_WS_BYTES, 1009), > (10, 10, 0), > (11, 10, 1009), > ], > ids=[ > "max=defaults sent=defaults", > "max=defaults sent=defaults+1", > "max=10 sent=10", > "max=10 sent=11", > ], > ) > async def test_send_binary_data_to_server_bigger_than_default( > protocol_cls, client_size_sent, server_size_max, expected_result > ): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > > async def websocket_receive(self, message): > _bytes = message.get("bytes") > await self.send({"type": "websocket.send", "bytes": _bytes}) > > async def send_text(url): > async with websockets.connect(url, max_size=client_size_sent) as websocket: > await websocket.send(b"\x01" * client_size_sent) > return await websocket.recv() > > config = Config( > app=App, ws=protocol_cls, lifespan="off", ws_max_size=server_size_max > ) > async with run_server(config): > if expected_result == 0: >> data = await send_text("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_send_binary_data_to_server_bigger_than_default.<locals>.App'> >client_size_sent = 10 >config = <uvicorn.config.Config object at 0x7f2bc6adb430> >expected_result = 0 >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >send_text = <function test_send_binary_data_to_server_bigger_than_default.<locals>.send_text at 0x7f2bc6c0a670> >server_size_max = 10 > >tests/protocols/test_websocket.py:505: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:496: in send_text > async with websockets.connect(url, max_size=client_size_sent) as websocket: > client_size_sent = 10 > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc7fbb8e0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7fbba00> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc7fbb8e0> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc7fbb970>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = '30vnQ0THVkl732Atc6Jciw==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', '30vnQ0THVkl732Atc6Jciw=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7fbba00> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7fbba00> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc7fbba00> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc6aa37c0> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >_ test_send_binary_data_to_server_bigger_than_default[max=10 sent=11-WebSocketProtocol] _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: >> status_line = await read_line(stream) > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:112: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_line(stream: asyncio.StreamReader) -> bytes: > """ > Read a single line from ``stream``. > > CRLF is stripped from the return value. > > """ > # Security: this is bounded by the StreamReader's limit (default = 32Â KiB). > line = await stream.readline() > # Security: this guarantees header values are small (hard-coded = 4Â KiB) > if len(line) > MAX_LINE: > raise SecurityError("line too long") > # Not mandatory but safe - https://tools.ietf.org/html/rfc7230#section-3.5 > if not line.endswith(b"\r\n"): >> raise EOFError("line without CRLF") >E EOFError: line without CRLF > >line = b'' >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:192: EOFError > >The above exception was the direct cause of the following exception: > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a76490> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: >> status_code, reason, headers = await read_response(self.reader) > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a76490> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:193: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > > async def read_response(stream: asyncio.StreamReader) -> Tuple[int, str, Headers]: > """ > Read an HTTP/1.1 response and return ``(status_code, reason, headers)``. > > ``reason`` and ``headers`` are expected to contain only ASCII characters. > Other characters are represented with surrogate escapes. > > :func:`read_request` doesn't attempt to read the response body because > WebSocket handshake responses don't have one. If the response contains a > body, it may be read from ``stream`` after this coroutine returns. > > :param stream: input to read the response from > :raises EOFError: if the connection is closed without a full HTTP response > :raises SecurityError: if the response exceeds a security limit > :raises ValueError: if the response isn't well formatted > > """ > # https://tools.ietf.org/html/rfc7230#section-3.1.2 > > # As in read_request, parsing is simple because a fixed value is expected > # for version, status_code is a 3-digit number, and reason can be ignored. > > try: > status_line = await read_line(stream) > except EOFError as exc: >> raise EOFError("connection closed while reading HTTP status line") from exc >E EOFError: connection closed while reading HTTP status line > >stream = <StreamReader eof limit=32768 transport=<_SelectorSocketTransport closed fd=15>> > >/usr/lib/python3.8/site-packages/websockets/legacy/http.py:114: EOFError > >The above exception was the direct cause of the following exception: > >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >client_size_sent = 11, server_size_max = 10, expected_result = 1009 > > @pytest.mark.asyncio > @pytest.mark.parametrize("protocol_cls", ONLY_WEBSOCKETPROTOCOL) > @pytest.mark.parametrize( > "client_size_sent, server_size_max, expected_result", > [ > (MAX_WS_BYTES, MAX_WS_BYTES, 0), > (MAX_WS_BYTES_PLUS1, MAX_WS_BYTES, 1009), > (10, 10, 0), > (11, 10, 1009), > ], > ids=[ > "max=defaults sent=defaults", > "max=defaults sent=defaults+1", > "max=10 sent=10", > "max=10 sent=11", > ], > ) > async def test_send_binary_data_to_server_bigger_than_default( > protocol_cls, client_size_sent, server_size_max, expected_result > ): > class App(WebSocketResponse): > async def websocket_connect(self, message): > await self.send({"type": "websocket.accept"}) > > async def websocket_receive(self, message): > _bytes = message.get("bytes") > await self.send({"type": "websocket.send", "bytes": _bytes}) > > async def send_text(url): > async with websockets.connect(url, max_size=client_size_sent) as websocket: > await websocket.send(b"\x01" * client_size_sent) > return await websocket.recv() > > config = Config( > app=App, ws=protocol_cls, lifespan="off", ws_max_size=server_size_max > ) > async with run_server(config): > if expected_result == 0: > data = await send_text("ws://127.0.0.1:8000") > assert data == b"\x01" * client_size_sent > else: > with pytest.raises(websockets.ConnectionClosedError) as e: >> data = await send_text("ws://127.0.0.1:8000") > >App = <class 'test_websocket.test_send_binary_data_to_server_bigger_than_default.<locals>.App'> >client_size_sent = 11 >config = <uvicorn.config.Config object at 0x7f2bc6c87220> >e = <ExceptionInfo for raises contextmanager> >expected_result = 1009 >protocol_cls = <class 'uvicorn.protocols.websockets.websockets_impl.WebSocketProtocol'> >send_text = <function test_send_binary_data_to_server_bigger_than_default.<locals>.send_text at 0x7f2bc6cc2ca0> >server_size_max = 10 > >tests/protocols/test_websocket.py:509: >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >tests/protocols/test_websocket.py:496: in send_text > async with websockets.connect(url, max_size=client_size_sent) as websocket: > client_size_sent = 11 > url = 'ws://127.0.0.1:8000' >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:608: in __aenter__ > return await self > self = <websockets.legacy.client.Connect object at 0x7f2bc6a764f0> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:633: in __await_impl__ > await protocol.handshake( > protocol = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a76490> > redirects = 0 > self = <websockets.legacy.client.Connect object at 0x7f2bc6a764f0> > transport = <_SelectorSocketTransport closed fd=15> >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:383: in handshake > status_code, response_headers = await self.read_http_response() > available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f2bc6a76430>] > available_subprotocols = None > extensions_header = 'permessage-deflate; client_max_window_bits' > extra_headers = None > key = 'JhjGaOhH9g0GX8BYi8z9Hw==' > origin = None > request_headers = Headers([('Host', '127.0.0.1:8000'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', 'JhjGaOhH9g0GX8BYi8z9Hw=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.8 websockets/9.1')]) > self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a76490> > wsuri = WebSocketURI(secure=False, host='127.0.0.1', port=8000, resource_name='/', user_info=None) >_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a76490> > > async def read_http_response(self) -> Tuple[int, Headers]: > """ > Read status line and headers from the HTTP response. > > If the response contains a body, it may be read from ``self.reader`` > after this coroutine returns. > > :raises ~websockets.exceptions.InvalidMessage: if the HTTP message is > malformed or isn't an HTTP/1.1 GET response > > """ > try: > status_code, reason, headers = await read_response(self.reader) > # Remove this branch when dropping support for Python < 3.8 > # because CancelledError no longer inherits Exception. > except asyncio.CancelledError: # pragma: no cover > raise > except Exception as exc: >> raise InvalidMessage("did not receive a valid HTTP response") from exc >E websockets.exceptions.InvalidMessage: did not receive a valid HTTP response > >self = <websockets.legacy.client.WebSocketClientProtocol object at 0x7f2bc6a76490> > >/usr/lib/python3.8/site-packages/websockets/legacy/client.py:199: InvalidMessage >----------------------------- Captured stderr call ----------------------------- >INFO: Started server process [70] >INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >INFO: Shutting down >------------------------------ Captured log call ------------------------------- >INFO uvicorn.error:server.py:65 Started server process [70] >INFO uvicorn.error:server.py:202 Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) >ERROR asyncio:base_events.py:1707 Fatal error: protocol.data_received() call failed. >protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x7f2bc6be91f0> >transport: <_SelectorSocketTransport fd=16 read=polling write=<idle, bufsize=0>> >Traceback (most recent call last): > File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received > self._protocol.data_received(data) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 131, in data_received > self.handle_events() > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 180, in handle_events > self.handle_upgrade(event) > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/http/h11_impl.py", line 264, in handle_upgrade > protocol = self.ws_protocol_class( > File "/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0/uvicorn/protocols/websockets/websockets_impl.py", line 62, in __init__ > super().__init__( > File "/usr/lib/python3.8/site-packages/websockets/legacy/server.py", line 201, in __init__ > super().__init__(**kwargs) > File "/usr/lib/python3.8/site-packages/websockets/legacy/protocol.py", line 135, in __init__ > assert loop is not None >AssertionError >INFO uvicorn.error:server.py:242 Shutting down >=========================== short test summary info ============================ >FAILED tests/test_auto_detection.py::test_websocket_auto - AssertionError >FAILED tests/protocols/test_websocket.py::test_invalid_upgrade[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_accept_connection[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_supports_permessage_deflate_extension[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_headers[WebSocketProtocol] - w... >FAILED tests/protocols/test_websocket.py::test_path_and_raw_path[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_send_text_data_to_client[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_send_binary_data_to_client[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_send_and_close_connection[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_send_text_data_to_server[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_send_binary_data_to_server[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_send_after_protocol_close[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_missing_handshake[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_send_before_handshake[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_duplicate_handshake[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_asgi_return_value[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_app_close[None-None-WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_app_close[None-1000-WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_app_close[None-1001-WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_app_close[test-None-WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_app_close[test-1000-WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_app_close[test-1001-WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_client_close[WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_subprotocols[proto1-WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_subprotocols[proto2-WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_send_binary_data_to_server_bigger_than_default[max=defaults sent=defaults-WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_send_binary_data_to_server_bigger_than_default[max=defaults sent=defaults+1-WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_send_binary_data_to_server_bigger_than_default[max=10 sent=10-WebSocketProtocol] >FAILED tests/protocols/test_websocket.py::test_send_binary_data_to_server_bigger_than_default[max=10 sent=11-WebSocketProtocol] >======================= 29 failed, 183 passed in 22.79s ======================== > * ERROR: dev-python/uvicorn-0.14.0-r1::gentoo failed (test phase): > * pytest failed with python3.8 > * > * Call stack: > * ebuild.sh, line 127: Called src_test > * environment, line 2996: Called distutils-r1_src_test > * environment, line 1292: Called _distutils-r1_run_foreach_impl 'python_test' > * environment, line 534: Called python_foreach_impl 'distutils-r1_run_phase' 'python_test' > * environment, line 2659: Called multibuild_foreach_variant '_python_multibuild_wrapper' 'distutils-r1_run_phase' 'python_test' > * environment, line 2132: Called _multibuild_run '_python_multibuild_wrapper' 'distutils-r1_run_phase' 'python_test' > * environment, line 2130: Called _python_multibuild_wrapper 'distutils-r1_run_phase' 'python_test' > * environment, line 848: Called distutils-r1_run_phase 'python_test' > * environment, line 1231: Called python_test > * environment, line 2955: Called distutils-r1_python_test > * environment, line 1188: Called epytest > * environment, line 1650: Called die > * The specific snippet of code: > * "${@}" || die -n "pytest failed with ${EPYTHON}"; > * > * If you need support, post the output of `emerge --info '=dev-python/uvicorn-0.14.0-r1::gentoo'`, > * the complete build log and the output of `emerge -pqv '=dev-python/uvicorn-0.14.0-r1::gentoo'`. > * The complete build log is located at '/var/log/emerge-log/build/dev-python/uvicorn-0.14.0-r1:20210805-185925.log'. > * For convenience, a symlink to the build log is located at '/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/temp/build.log'. > * The ebuild environment file is located at '/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/temp/environment'. > * Working directory: '/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0' > * S: '/var/tmp/portage/dev-python/uvicorn-0.14.0-r1/work/uvicorn-0.14.0' >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 806671
: 730597