Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
OpenVMS
Python
Modules
pika
Commits
30ab143c1921
Commit
30ab143c1921
authored
7 years ago
by
Luke Bakken
Browse files
Options
Downloads
Patches
Plain Diff
Pika heartbeat sending and checking now behaves exactly as the Java client
parent
31d2d01280b9
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pika/heartbeat.py
+16
-1
16 additions, 1 deletion
pika/heartbeat.py
tests/unit/heartbeat_tests.py
+1
-1
1 addition, 1 deletion
tests/unit/heartbeat_tests.py
with
17 additions
and
2 deletions
pika/heartbeat.py
+
16
−
1
View file @
30ab143c
...
@@ -34,6 +34,9 @@
...
@@ -34,6 +34,9 @@
this value by dividing it by two.
this value by dividing it by two.
"""
"""
if
timeout
<
1
:
raise
ValueError
(
'
timeout must >= 0, but got %r
'
%
(
timeout
,))
self
.
_connection
=
connection
self
.
_connection
=
connection
# Note: see the following documents:
# Note: see the following documents:
...
@@ -46,4 +49,5 @@
...
@@ -46,4 +49,5 @@
# heartbeat. This is to avoid edge cases and not to depend on network
# heartbeat. This is to avoid edge cases and not to depend on network
# latency.
# latency.
self
.
_timeout
=
timeout
self
.
_timeout
=
timeout
self
.
_send_interval
=
float
(
timeout
)
/
2
self
.
_send_interval
=
float
(
timeout
)
/
2
...
@@ -49,5 +53,16 @@
...
@@ -49,5 +53,16 @@
self
.
_send_interval
=
float
(
timeout
)
/
2
self
.
_send_interval
=
float
(
timeout
)
/
2
self
.
_check_interval
=
timeout
# Note: Pika doubles the negotiated timeout to match the behavior of the
# RabbitMQ Java client and the spec that suggests a check interval equivalent
# to two times the heartbeat timeout value.
# https://github.com/pika/pika/pull/1072#issuecomment-397850795
# https://github.com/rabbitmq/rabbitmq-java-client/blob/b55bd20a1a236fc2d1ea9369b579770fa0237615/src/main/java/com/rabbitmq/client/impl/AMQConnection.java#L773-L780
self
.
_check_interval
=
float
(
timeout
)
*
2
;
LOGGER
.
debug
(
'
timeout: %f send_interval: %f check_interval: %f
'
,
self
.
_timeout
,
self
.
_send_interval
,
self
.
_check_interval
)
# Initialize counters
# Initialize counters
self
.
_bytes_received
=
0
self
.
_bytes_received
=
0
...
...
This diff is collapsed.
Click to expand it.
tests/unit/heartbeat_tests.py
+
1
−
1
View file @
30ab143c
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
INTERVAL
=
60
INTERVAL
=
60
SEND_INTERVAL
=
float
(
INTERVAL
)
/
2
SEND_INTERVAL
=
float
(
INTERVAL
)
/
2
CHECK_INTERVAL
=
INTERVAL
CHECK_INTERVAL
=
float
(
INTERVAL
)
*
2
def
setUp
(
self
):
def
setUp
(
self
):
self
.
mock_conn
=
mock
.
Mock
(
spec
=
connection
.
Connection
)
self
.
mock_conn
=
mock
.
Mock
(
spec
=
connection
.
Connection
)
...
...
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