Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
ZEO
Commits
4545308c
Commit
4545308c
authored
Sep 07, 2001
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New file from zeo-1_0-branch.
Wrap asyncore calls and be careful about exceptions.
parent
41e389f5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
src/ZEO/asyncwrap.py
src/ZEO/asyncwrap.py
+44
-0
No files found.
src/ZEO/asyncwrap.py
0 → 100644
View file @
4545308c
"""A wrapper for asyncore that provides robust exception handling.
The poll() and loop() calls exported by asyncore can raise exceptions.
asyncore uses either the select() or poll() system call. It is
possible for those system calls to fail, returning, for example,
EINTR. Python raises a select.error when an error occurs. If the
program using asyncore doesn't catch the exception, it will die with
an uncaught exception.
This module exports safer versions of loop() and poll() that wrap the
asyncore calls in try/except handlers that catch the errors and do the
right thing. In most cases, it is safe to catch the error and simply
retry the call.
XXX Operations on asyncore sockets can also fail with exceptions that
can safely be caught and ignored by user programs. It's not clear if
it would be useful to extend this module with wrappers for those
errors.
"""
# XXX The current implementation requires Python 2.0. Not sure if
# that's acceptable, depends on how many users want to combine ZEO 1.0
# and Zope 2.3.
import
asyncore
import
errno
import
select
def
loop
(
*
args
,
**
kwargs
):
while
1
:
try
:
apply
(
asyncore
.
loop
,
args
,
kwargs
)
except
select
.
error
,
err
:
if
err
[
0
]
!=
errno
.
EINTR
:
raise
else
:
break
def
poll
(
*
args
,
**
kwargs
):
try
:
apply
(
asyncore
.
poll
,
args
,
kwargs
)
except
select
.
error
,
err
:
if
err
[
0
]
!=
errno
.
EINTR
:
raise
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