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
904ac85c
Commit
904ac85c
authored
Sep 15, 2010
by
Ralf Schmitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backdoor.py: simplify code. also close connection on SystemExit.
parent
dc3493ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
26 deletions
+11
-26
changelog.rst
changelog.rst
+1
-1
gevent/backdoor.py
gevent/backdoor.py
+10
-25
No files found.
changelog.rst
View file @
904ac85c
...
...
@@ -43,7 +43,7 @@ Miscellaneous:
- Fixed ``webproxy.py`` example to be runnable under external WSGI server.
- Fixed bogus failure in ``test__exc_info.py``.
- Added new test to check PEP8 conformance: ``xtest_pep8.py``
- Made :class:`BackdoorServer` close the connection on SystemExit and simplified the code
Version 0.13.0
--------------
...
...
gevent/backdoor.py
View file @
904ac85c
...
...
@@ -47,32 +47,9 @@ class SocketConsole(Greenlet):
def
__init__
(
self
,
locals
,
conn
):
Greenlet
.
__init__
(
self
)
self
.
locals
=
locals
# mangle the socket
desc
=
self
.
desc
=
_fileobject
(
conn
)
readline
=
desc
.
readline
self
.
old
=
{}
self
.
fixups
=
{
'softspace'
:
0
,
'isatty'
:
lambda
:
True
,
'flush'
:
lambda
:
None
,
'readline'
:
lambda
*
a
:
readline
(
*
a
).
replace
(
'
\
r
\
n
'
,
'
\
n
'
),
}
for
key
,
value
in
self
.
fixups
.
iteritems
():
if
hasattr
(
desc
,
key
):
self
.
old
[
key
]
=
getattr
(
desc
,
key
)
setattr
(
desc
,
key
,
value
)
self
.
desc
=
_fileobject
(
conn
)
def
finalize
(
self
):
# restore the state of the socket
for
key
in
self
.
fixups
:
try
:
value
=
self
.
old
[
key
]
except
KeyError
:
delattr
(
self
.
desc
,
key
)
else
:
setattr
(
self
.
desc
,
key
,
value
)
self
.
fixups
.
clear
()
self
.
old
.
clear
()
self
.
desc
=
None
def
switch
(
self
,
*
args
,
**
kw
):
...
...
@@ -89,7 +66,7 @@ class SocketConsole(Greenlet):
console
=
InteractiveConsole
(
self
.
locals
)
console
.
interact
()
except
SystemExit
:
# raised by quit()
pass
sys
.
exc_clear
()
finally
:
self
.
switch_out
()
self
.
finalize
()
...
...
@@ -111,6 +88,14 @@ class _fileobject(socket._fileobject):
def
write
(
self
,
data
):
self
.
_sock
.
sendall
(
data
)
def
isatty
(
self
):
return
True
def
flush
(
self
):
pass
def
readline
(
self
,
*
a
):
return
socket
.
_fileobject
.
readline
(
self
,
*
a
).
replace
(
"
\
r
\
n
"
,
"
\
n
"
)
if
__name__
==
'__main__'
:
if
not
sys
.
argv
[
1
:]:
...
...
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