Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
df90b024
Commit
df90b024
authored
Mar 31, 2009
by
Josiah Carlson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This resolves issue 1161031. Tests pass.
parent
73fba691
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
27 deletions
+25
-27
Lib/asyncore.py
Lib/asyncore.py
+25
-27
No files found.
Lib/asyncore.py
View file @
df90b024
...
@@ -69,10 +69,12 @@ def _strerror(err):
...
@@ -69,10 +69,12 @@ def _strerror(err):
class
ExitNow
(
Exception
):
class
ExitNow
(
Exception
):
pass
pass
_reraised_exceptions
=
(
ExitNow
,
KeyboardInterrupt
,
SystemExit
)
def
read
(
obj
):
def
read
(
obj
):
try
:
try
:
obj
.
handle_read_event
()
obj
.
handle_read_event
()
except
(
ExitNow
,
KeyboardInterrupt
,
SystemExit
)
:
except
_reraised_exceptions
:
raise
raise
except
:
except
:
obj
.
handle_error
()
obj
.
handle_error
()
...
@@ -80,7 +82,7 @@ def read(obj):
...
@@ -80,7 +82,7 @@ def read(obj):
def
write
(
obj
):
def
write
(
obj
):
try
:
try
:
obj
.
handle_write_event
()
obj
.
handle_write_event
()
except
(
ExitNow
,
KeyboardInterrupt
,
SystemExit
)
:
except
_reraised_exceptions
:
raise
raise
except
:
except
:
obj
.
handle_error
()
obj
.
handle_error
()
...
@@ -88,22 +90,22 @@ def write(obj):
...
@@ -88,22 +90,22 @@ def write(obj):
def
_exception
(
obj
):
def
_exception
(
obj
):
try
:
try
:
obj
.
handle_expt_event
()
obj
.
handle_expt_event
()
except
(
ExitNow
,
KeyboardInterrupt
,
SystemExit
)
:
except
_reraised_exceptions
:
raise
raise
except
:
except
:
obj
.
handle_error
()
obj
.
handle_error
()
def
readwrite
(
obj
,
flags
):
def
readwrite
(
obj
,
flags
):
try
:
try
:
if
flags
&
(
select
.
POLLIN
|
select
.
POLLPRI
):
if
flags
&
select
.
POLLPRI
:
obj
.
handle_expt_event
()
if
flags
&
select
.
POLLIN
:
obj
.
handle_read_event
()
obj
.
handle_read_event
()
if
flags
&
select
.
POLLOUT
:
if
flags
&
select
.
POLLOUT
:
obj
.
handle_write_event
()
obj
.
handle_write_event
()
if
flags
&
(
select
.
POLLERR
|
select
.
POLLNVAL
):
if
flags
&
(
select
.
POLLHUP
|
select
.
POLLERR
|
select
.
POLLNVAL
):
obj
.
handle_expt_event
()
if
flags
&
select
.
POLLHUP
:
obj
.
handle_close
()
obj
.
handle_close
()
except
(
ExitNow
,
KeyboardInterrupt
,
SystemExit
)
:
except
_reraised_exceptions
:
raise
raise
except
:
except
:
obj
.
handle_error
()
obj
.
handle_error
()
...
@@ -211,6 +213,7 @@ class dispatcher:
...
@@ -211,6 +213,7 @@ class dispatcher:
accepting
=
False
accepting
=
False
closing
=
False
closing
=
False
addr
=
None
addr
=
None
ignore_log_types
=
frozenset
([
'warning'
])
def
__init__
(
self
,
sock
=
None
,
map
=
None
):
def
__init__
(
self
,
sock
=
None
,
map
=
None
):
if
map
is
None
:
if
map
is
None
:
...
@@ -398,7 +401,7 @@ class dispatcher:
...
@@ -398,7 +401,7 @@ class dispatcher:
sys
.
stderr
.
write
(
'log: %s
\
n
'
%
str
(
message
))
sys
.
stderr
.
write
(
'log: %s
\
n
'
%
str
(
message
))
def
log_info
(
self
,
message
,
type
=
'info'
):
def
log_info
(
self
,
message
,
type
=
'info'
):
if
__debug__
or
type
!=
'info'
:
if
__debug__
or
type
not
in
self
.
ignore_log_types
:
print
'%s: %s'
%
(
type
,
message
)
print
'%s: %s'
%
(
type
,
message
)
def
handle_read_event
(
self
):
def
handle_read_event
(
self
):
...
@@ -432,22 +435,17 @@ class dispatcher:
...
@@ -432,22 +435,17 @@ class dispatcher:
self
.
handle_write
()
self
.
handle_write
()
def
handle_expt_event
(
self
):
def
handle_expt_event
(
self
):
# if the handle_expt is the same default worthless method,
# handle_expt_event() is called if there might be an error on the
# we'll not even bother calling it, we'll instead generate
# socket, or if there is OOB data
# a useful error
# check for the error condition first
x
=
True
err
=
self
.
socket
.
getsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_ERROR
)
try
:
if
err
!=
0
:
y1
=
self
.
__class__
.
handle_expt
.
im_func
# we can get here when select.select() says that there is an
y2
=
dispatcher
.
handle_expt
.
im_func
# exceptional condition on the socket
x
=
y1
is
y2
# since there is an error, we'll go ahead and close the socket
except
AttributeError
:
# like we would in a subclassed handle_read() that received no
pass
# data
self
.
handle_close
()
if
x
:
err
=
self
.
socket
.
getsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_ERROR
)
msg
=
_strerror
(
err
)
raise
socket
.
error
(
err
,
msg
)
else
:
else
:
self
.
handle_expt
()
self
.
handle_expt
()
...
@@ -472,7 +470,7 @@ class dispatcher:
...
@@ -472,7 +470,7 @@ class dispatcher:
self
.
handle_close
()
self
.
handle_close
()
def
handle_expt
(
self
):
def
handle_expt
(
self
):
self
.
log_info
(
'unhandled
exception
'
,
'warning'
)
self
.
log_info
(
'unhandled
incoming priority event
'
,
'warning'
)
def
handle_read
(
self
):
def
handle_read
(
self
):
self
.
log_info
(
'unhandled read event'
,
'warning'
)
self
.
log_info
(
'unhandled read event'
,
'warning'
)
...
@@ -553,7 +551,7 @@ def close_all(map=None, ignore_all=False):
...
@@ -553,7 +551,7 @@ def close_all(map=None, ignore_all=False):
pass
pass
elif
not
ignore_all
:
elif
not
ignore_all
:
raise
raise
except
(
ExitNow
,
KeyboardInterrupt
,
SystemExit
)
:
except
_reraised_exceptions
:
raise
raise
except
:
except
:
if
not
ignore_all
:
if
not
ignore_all
:
...
...
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