You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
confound pointed out that $fh as a file handle might not work if it's not line-ending, or performance poorly. Can we let them support read instead? Or let implementors to specify a callback that app can optionally set file handle back (like the case of AnyEvent?)
Duck typing read() and getline() on perl objects and filehandles are hard.
From PEP333:
Some operating environments provide special high-performance file- transmission facilities, such as the Unix sendfile() call. Servers and gateways may expose this functionality via an optional wsgi.file_wrapper key in the environ. An application may use this "file wrapper" to convert a file or file-like object into an iterable that it then returns, e.g.:
if 'wsgi.file_wrapper' in environ:
return environ['wsgi.file_wrapper'](filelike, block_size)
else:
return iter(lambda: filelike.read(block_size), '')
To be considered "file-like", the object supplied by the application must have a read() method that takes an optional size argument. It may have a close() method, and if so, the iterable returned by wsgi.file_wrapper must have a close() method that invokes the original file-like object's close() method.
The text was updated successfully, but these errors were encountered:
13:12 tiarra: 13:11:26 >miyagawa< yay
13:12 tiarra: 13:11:26 >miyagawa< so I talked with nothingmuch for like half an hour
13:13 miyagawa: getline is kept. read is not because it's not easy to write read() mock
13:13 Mode: +n
13:13 Created at: 2008/04/30 00:02
13:13 miyagawa: but getline is
13:13 miyagawa: and if backends want to read binary then just use fileno to check if it's a real filehandle
13:13 miyagawa: and/or do local $/ = $bytes; to do chunking
confound pointed out that $fh as a file handle might not work if it's not line-ending, or performance poorly. Can we let them support read instead? Or let implementors to specify a callback that app can optionally set file handle back (like the case of AnyEvent?)
Duck typing read() and getline() on perl objects and filehandles are hard.
From PEP333:
Some operating environments provide special high-performance file- transmission facilities, such as the Unix sendfile() call. Servers and gateways may expose this functionality via an optional wsgi.file_wrapper key in the environ. An application may use this "file wrapper" to convert a file or file-like object into an iterable that it then returns, e.g.:
if 'wsgi.file_wrapper' in environ:
return environ['wsgi.file_wrapper'](filelike, block_size)
else:
return iter(lambda: filelike.read(block_size), '')
To be considered "file-like", the object supplied by the application must have a read() method that takes an optional size argument. It may have a close() method, and if so, the iterable returned by wsgi.file_wrapper must have a close() method that invokes the original file-like object's close() method.
The text was updated successfully, but these errors were encountered: