Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pulsar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NDIP
Pulsar
Commits
679137dc
Commit
679137dc
authored
8 years ago
by
Nate Coraor
Browse files
Options
Downloads
Patches
Plain Diff
Support timeout handling in the standard (urllib-based) client
transport.
parent
ec577686
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pulsar/client/transport/standard.py
+14
-5
14 additions, 5 deletions
pulsar/client/transport/standard.py
with
14 additions
and
5 deletions
pulsar/client/transport/standard.py
+
14
−
5
View file @
679137dc
...
@@ -4,23 +4,27 @@ Pulsar HTTP Client layer based on Python Standard Library (urllib2)
...
@@ -4,23 +4,27 @@ Pulsar HTTP Client layer based on Python Standard Library (urllib2)
from
__future__
import
with_statement
from
__future__
import
with_statement
from
os.path
import
getsize
from
os.path
import
getsize
import
mmap
import
mmap
import
socket
try
:
try
:
from
urllib2
import
urlopen
from
urllib2
import
urlopen
,
URLError
except
ImportError
:
except
ImportError
:
from
urllib.request
import
urlopen
from
urllib.request
import
urlopen
from
urllib.error
import
URLError
try
:
try
:
from
urllib2
import
Request
from
urllib2
import
Request
except
ImportError
:
except
ImportError
:
from
urllib.request
import
Request
from
urllib.request
import
Request
from
..exceptions
import
PulsarClientTransportError
class
Urllib2Transport
(
object
):
class
Urllib2Transport
(
object
):
def
__init__
(
self
,
**
kwrgs
):
def
__init__
(
self
,
timeout
=
None
,
**
kwrgs
):
pass
self
.
timeout
=
timeout
def
_url_open
(
self
,
request
,
data
):
def
_url_open
(
self
,
request
,
data
):
return
urlopen
(
request
,
data
)
return
urlopen
(
request
,
data
,
self
.
timeout
)
def
execute
(
self
,
url
,
method
=
None
,
data
=
None
,
input_path
=
None
,
output_path
=
None
):
def
execute
(
self
,
url
,
method
=
None
,
data
=
None
,
input_path
=
None
,
output_path
=
None
):
request
=
self
.
__request
(
url
,
data
,
method
)
request
=
self
.
__request
(
url
,
data
,
method
)
...
@@ -34,7 +38,12 @@ class Urllib2Transport(object):
...
@@ -34,7 +38,12 @@ class Urllib2Transport(object):
else
:
else
:
data
=
b
""
data
=
b
""
request
.
add_header
(
'
Content-Length
'
,
str
(
size
))
request
.
add_header
(
'
Content-Length
'
,
str
(
size
))
response
=
self
.
_url_open
(
request
,
data
)
try
:
response
=
self
.
_url_open
(
request
,
data
)
except
socket
.
timeout
as
exc
:
raise
PulsarClientTransportError
(
code
=
PulsarClientTransportError
.
TIMEOUT
)
except
URLError
as
exc
:
raise
PulsarClientTransportError
(
transport_message
=
exc
.
reason
)
finally
:
finally
:
if
input
:
if
input
:
input
.
close
()
input
.
close
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment