Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
coolamqp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
coolamqp
Commits
90c55f26
Commit
90c55f26
authored
8 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
cleanup again
parent
22df4260
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
coolamqp/cluster.py
+3
-3
3 additions, 3 deletions
coolamqp/cluster.py
coolamqp/handler.py
+3
-3
3 additions, 3 deletions
coolamqp/handler.py
with
6 additions
and
6 deletions
coolamqp/cluster.py
+
3
−
3
View file @
90c55f26
...
@@ -211,15 +211,15 @@ class Cluster(object):
...
@@ -211,15 +211,15 @@ class Cluster(object):
self
.
thread
.
start
()
self
.
thread
.
start
()
return
self
return
self
def
shutdown
(
self
,
complete_
outstand
ing_tasks
=
False
):
def
shutdown
(
self
,
complete_
remain
ing_tasks
=
False
):
"""
"""
Cleans everything and returns.
Cleans everything and returns.
:param complete_
outstanding
_tasks: if set to True, pending operations will be completed.
:param complete_
remaining_tasks
_tasks: if set to True, pending operations will be completed.
If False, thread will exit without completing them.
If False, thread will exit without completing them.
This can mean that if the cluster doesn
'
t come up online, shutdown MAY BLOCK FOREVER.
This can mean that if the cluster doesn
'
t come up online, shutdown MAY BLOCK FOREVER.
"""
"""
self
.
thread
.
complete_
outstand
ing_upon_termination
=
complete_
outstand
ing_tasks
self
.
thread
.
complete_
remain
ing_upon_termination
=
complete_
remain
ing_tasks
self
.
thread
.
terminate
()
self
.
thread
.
terminate
()
self
.
thread
.
join
()
self
.
thread
.
join
()
# thread closes the AMQP uplink for us
# thread closes the AMQP uplink for us
This diff is collapsed.
Click to expand it.
coolamqp/handler.py
+
3
−
3
View file @
90c55f26
...
@@ -17,7 +17,7 @@ logger = logging.getLogger(__name__)
...
@@ -17,7 +17,7 @@ logger = logging.getLogger(__name__)
class
_ImOuttaHere
(
Exception
):
class
_ImOuttaHere
(
Exception
):
"""
Thrown upon thread terminating.
"""
Thrown upon thread terminating.
Thrown only if complete_
outstand
ing_upon_termination is False
"""
Thrown only if complete_
remain
ing_upon_termination is False
"""
class
ClusterHandlerThread
(
threading
.
Thread
):
class
ClusterHandlerThread
(
threading
.
Thread
):
...
@@ -32,7 +32,7 @@ class ClusterHandlerThread(threading.Thread):
...
@@ -32,7 +32,7 @@ class ClusterHandlerThread(threading.Thread):
self
.
cluster
=
cluster
self
.
cluster
=
cluster
self
.
is_terminating
=
False
self
.
is_terminating
=
False
self
.
complete_
outstand
ing_upon_termination
=
False
self
.
complete_
remain
ing_upon_termination
=
False
self
.
order_queue
=
collections
.
deque
()
# queue for inbound orders
self
.
order_queue
=
collections
.
deque
()
# queue for inbound orders
self
.
event_queue
=
queue
.
Queue
()
# queue for tasks done
self
.
event_queue
=
queue
.
Queue
()
# queue for tasks done
self
.
connect_id
=
-
1
# connectID of current connection
self
.
connect_id
=
-
1
# connectID of current connection
...
@@ -81,7 +81,7 @@ class ClusterHandlerThread(threading.Thread):
...
@@ -81,7 +81,7 @@ class ClusterHandlerThread(threading.Thread):
self
.
backend
=
None
# good policy to release resources before you sleep
self
.
backend
=
None
# good policy to release resources before you sleep
time
.
sleep
(
exponential_backoff_delay
)
time
.
sleep
(
exponential_backoff_delay
)
if
self
.
is_terminating
and
(
not
self
.
complete_
outstand
ing_upon_termination
):
if
self
.
is_terminating
and
(
not
self
.
complete_
remain
ing_upon_termination
):
raise
_ImOuttaHere
()
raise
_ImOuttaHere
()
exponential_backoff_delay
=
min
(
60
,
exponential_backoff_delay
*
2
)
exponential_backoff_delay
=
min
(
60
,
exponential_backoff_delay
*
2
)
...
...
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