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
65396622
Commit
65396622
authored
Jun 18, 2012
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add FileObjectBlock (for testing, to rule-out fileobject-related bugs)
parent
6ecfc962
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
gevent/fileobject.py
gevent/fileobject.py
+25
-1
No files found.
gevent/fileobject.py
View file @
65396622
...
...
@@ -282,10 +282,34 @@ except NameError:
FileObject
=
FileObjectThreadPool
class
FileObjectBlock
(
object
):
def
__init__
(
self
,
fobj
,
*
args
,
**
kwargs
):
self
.
_close
=
kwargs
.
pop
(
'close'
,
True
)
if
kwargs
:
raise
TypeError
(
'Unexpected arguments: %r'
%
kwargs
.
keys
())
if
isinstance
(
fobj
,
(
int
,
long
)):
if
not
self
.
_close
:
# we cannot do this, since fdopen object will close the descriptor
raise
TypeError
(
'FileObjectBlock does not support close=False'
)
fobj
=
os
.
fdopen
(
fobj
,
*
args
)
self
.
_fobj
=
fobj
def
__repr__
(
self
):
return
'<%s %r>'
%
(
self
.
_fobj
,
)
def
__getattr__
(
self
,
item
):
assert
item
!=
'_fobj'
if
self
.
_fobj
is
None
:
raise
FileObjectClosed
return
getattr
(
self
.
_fobj
,
item
)
config
=
os
.
environ
.
get
(
'GEVENT_FILE'
)
if
config
:
klass
=
{
'thread'
:
'gevent.fileobject.FileObjectThreadPool'
,
'posix'
:
'gevent.fileobject.FileObjectPosix'
}.
get
(
config
,
config
)
'posix'
:
'gevent.fileobject.FileObjectPosix'
,
'block'
:
'gevent.fileobject.FileObjectBlock'
}.
get
(
config
,
config
)
if
klass
.
startswith
(
'gevent.fileobject.'
):
FileObject
=
globals
()[
klass
.
split
(
'.'
,
2
)[
-
1
]]
else
:
...
...
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