Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caucase
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vincent Pelletier
caucase
Commits
35f061c7
Commit
35f061c7
authored
Dec 14, 2018
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: Catch an occasional error not handled in standard library.
parent
9e773253
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
caucase/http.py
caucase/http.py
+35
-0
No files found.
caucase/http.py
View file @
35f061c7
...
...
@@ -22,6 +22,7 @@ from __future__ import absolute_import, print_function
import
argparse
from
collections
import
defaultdict
import
datetime
import
errno
from
getpass
import
getpass
import
glob
import
itertools
...
...
@@ -95,6 +96,40 @@ class ThreadingWSGIServer(ThreadingMixIn, WSGIServer):
self
.
socket
.
setsockopt
(
socket
.
IPPROTO_IPV6
,
socket
.
IPV6_V6ONLY
,
1
)
WSGIServer
.
server_bind
(
self
)
# pylint: disable=arguments-differ
def
serve_forever
(
self
,
*
args
,
**
kw
):
"""
Handle one request at a time until shutdown.
In addition to python's version:
- intercept EBADF on shutdown if select is interrupted:
"""
try
:
return
WSGIServer
.
serve_forever
(
self
,
*
args
,
**
kw
)
except
socket
.
error
as
exception
:
# Workaround for the following unhandled error:
# Traceback (most recent call last):
# File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
# self.run()
# File "/usr/lib/python2.7/threading.py", line 754, in run
# self.__target(*self.__args, **self.__kwargs)
# File "/usr/lib/python2.7/SocketServer.py", line 231, in serve_forever
# poll_interval)
# File "/usr/lib/python2.7/SocketServer.py", line 150, in _eintr_retry
# return func(*args)
# File "/usr/lib/python2.7/SocketServer.py", line 459, in fileno
# return self.socket.fileno()
# File "/usr/lib/python2.7/socket.py", line 228, in meth
# return getattr(self._sock,name)(*args)
# File "/usr/lib/python2.7/socket.py", line 174, in _dummy
# raise error(EBADF, 'Bad file descriptor')
# error: [Errno 9] Bad file descriptor
# Sadly, self.__shutdown_request is not accessible from here, so do not
# check any further.
if
exception
.
errno
!=
errno
.
EBADF
:
raise
# pylint: enable=arguments-differ
def
_buildQuoteCharList
():
# All chars considered guilty
result
=
[
'
\
\
x%02x'
%
x
for
x
in
xrange
(
256
)]
...
...
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