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
a798db09
Commit
a798db09
authored
May 05, 2012
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FileObjectThreadPool: do not allow close=False since fdopen does not support that
parent
84730b83
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
+19
-13
gevent/fileobject.py
gevent/fileobject.py
+15
-10
gevent/subprocess.py
gevent/subprocess.py
+4
-3
No files found.
gevent/fileobject.py
View file @
a798db09
...
...
@@ -212,14 +212,19 @@ else:
class
FileObjectThreadPool
(
object
):
def
__init__
(
self
,
fobj
,
mode
=
'rb'
,
bufsize
=-
1
,
close
=
True
,
threadpool
=
None
):
def
__init__
(
self
,
fobj
,
*
args
,
**
kwargs
):
self
.
_close
=
kwargs
.
pop
(
'close'
,
True
)
self
.
threadpool
=
kwargs
.
pop
(
'threadpool'
,
None
)
if
kwargs
:
raise
TypeError
(
'Unexpected arguments: %r'
%
kwargs
.
keys
())
if
isinstance
(
fobj
,
(
int
,
long
)):
fobj
=
os
.
fdopen
(
fobj
,
mode
,
bufsize
)
if
not
self
.
_close
:
# we cannot do this, since fdopen object will close the descriptor
raise
TypeError
(
'FileObjectThreadPool does not support close=False'
)
fobj
=
os
.
fdopen
(
fobj
,
*
args
)
self
.
_fobj
=
fobj
self
.
_close
=
close
if
threadpool
is
None
:
threadpool
=
get_hub
().
threadpool
self
.
threadpool
=
threadpool
if
self
.
threadpool
is
None
:
self
.
threadpool
=
get_hub
().
threadpool
def
close
(
self
):
fobj
=
self
.
_fobj
...
...
@@ -227,14 +232,14 @@ class FileObjectThreadPool(object):
return
self
.
_fobj
=
None
try
:
self
.
flush
(
_
_
fobj
=
fobj
)
self
.
flush
(
_fobj
=
fobj
)
finally
:
if
self
.
_close
:
fobj
.
close
()
def
flush
(
self
,
_
_
fobj
=
None
):
if
_
_
fobj
is
not
None
:
fobj
=
_
_
fobj
def
flush
(
self
,
_fobj
=
None
):
if
_fobj
is
not
None
:
fobj
=
_fobj
else
:
fobj
=
self
.
_fobj
if
fobj
is
None
:
...
...
gevent/subprocess.py
View file @
a798db09
...
...
@@ -593,11 +593,12 @@ class Popen(object):
# Wait for exec to fail or succeed; possibly raising exception
# Exception limited to 1M
data
=
FileObject
(
errpipe_read
,
'rb'
,
close
=
False
).
read
(
1048576
)
data
=
FileObject
(
errpipe_read
,
'rb'
).
read
(
1048576
)
errpipe_read
=
None
finally
:
# be sure the FD is closed no matter what
try
:
os
.
close
(
errpipe_read
)
if
errpipe_read
is
not
None
:
os
.
close
(
errpipe_read
)
except
EnvironmentError
:
pass
...
...
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