Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
a4f5ae39
Commit
a4f5ae39
authored
Oct 26, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documentation for FileObjectPosix to clarify the question in #673. [skip ci]
parent
1cacd69c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
gevent/_fileobjectposix.py
gevent/_fileobjectposix.py
+21
-0
gevent/fileobject.py
gevent/fileobject.py
+3
-1
No files found.
gevent/_fileobjectposix.py
View file @
a4f5ae39
...
@@ -127,6 +127,27 @@ class FileObjectPosix(object):
...
@@ -127,6 +127,27 @@ class FileObjectPosix(object):
A file-like object that operates on non-blocking files but
A file-like object that operates on non-blocking files but
provides a synchronous, cooperative interface.
provides a synchronous, cooperative interface.
.. caution::
This object is most effective wrapping files that can be used appropriately
with :func:`select.select` such as sockets and pipes.
In general, on most platforms, operations on regular files
(e.g., ``open('/etc/hosts')``) are considered non-blocking
already, even though they can take some time to complete as
data is copied to the kernel and flushed to disk (this time
is relatively bounded compared to sockets or pipes, though).
A :func:`~os.read` or :func:`~os.write` call on such a file
will still effectively block for some small period of time.
Therefore, wrapping this class around a regular file is
unlikely to make IO gevent-friendly: reading or writing large
amounts of data could still block the event loop.
If you'll be working with regular files and doing IO in large
chunks, you may consider using
:class:`~gevent.fileobject.FileObjectThread` or
:func:`~gevent.os.tp_read` and :func:`~gevent.os.tp_write` to bypass this
concern.
.. note::
.. note::
Random read/write (e.g., ``mode='rwb'``) is not supported.
Random read/write (e.g., ``mode='rwb'``) is not supported.
For that, use :class:`io.BufferedRWPair` around two instance of this
For that, use :class:`io.BufferedRWPair` around two instance of this
...
...
gevent/fileobject.py
View file @
a4f5ae39
...
@@ -16,7 +16,6 @@ A third class, :class:`FileObjectBlock`, is simply a wrapper that executes every
...
@@ -16,7 +16,6 @@ A third class, :class:`FileObjectBlock`, is simply a wrapper that executes every
synchronously (and so is not gevent-compatible). It is provided for testing and debugging
synchronously (and so is not gevent-compatible). It is provided for testing and debugging
purposes.
purposes.
Configuration
Configuration
=============
=============
...
@@ -30,6 +29,9 @@ objects.
...
@@ -30,6 +29,9 @@ objects.
.. note:: The environment variable must be set at the time this module
.. note:: The environment variable must be set at the time this module
is first imported.
is first imported.
Classes
=======
"""
"""
from
__future__
import
absolute_import
from
__future__
import
absolute_import
import
sys
import
sys
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment