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
f970e359
Commit
f970e359
authored
8 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
done
#3
parent
17b3d77f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
coolamqp/backends/__init__.py
+1
-1
1 addition, 1 deletion
coolamqp/backends/__init__.py
coolamqp/backends/base.py
+3
-1
3 additions, 1 deletion
coolamqp/backends/base.py
coolamqp/handler.py
+5
-1
5 additions, 1 deletion
coolamqp/handler.py
coolamqp/orders.py
+10
-1
10 additions, 1 deletion
coolamqp/orders.py
with
19 additions
and
4 deletions
coolamqp/backends/__init__.py
+
1
−
1
View file @
f970e359
#coding=UTF-8
from
.pyamqp
import
PyAMQPBackend
from
.base
import
AMQPError
,
ConnectionFailedError
,
RemoteAMQPError
from
.base
import
AMQPError
,
ConnectionFailedError
,
RemoteAMQPError
,
Cancelled
This diff is collapsed.
Click to expand it.
coolamqp/backends/base.py
+
3
−
1
View file @
f970e359
#coding=UTF-8
class
AMQPError
(
Exception
):
pass
"""
Connection errors and bawking of AMQP server
"""
class
ConnectionFailedError
(
AMQPError
):
"""
Connection to broker failed
"""
class
Cancelled
(
Exception
):
"""
Cancel ordered by user
"""
class
RemoteAMQPError
(
AMQPError
):
"""
...
...
This diff is collapsed.
Click to expand it.
coolamqp/handler.py
+
5
−
1
View file @
f970e359
...
...
@@ -4,7 +4,7 @@ import six.moves.queue as Queue
import
logging
import
collections
import
time
from
.backends
import
ConnectionFailedError
,
RemoteAMQPError
from
.backends
import
ConnectionFailedError
,
RemoteAMQPError
,
Cancelled
from
.messages
import
Exchange
from
.events
import
ConnectionUp
,
ConnectionDown
,
ConsumerCancelled
,
MessageReceived
from
.orders
import
SendMessage
,
DeclareExchange
,
ConsumeQueue
,
CancelQueue
,
\
...
...
@@ -96,6 +96,10 @@ class ClusterHandlerThread(threading.Thread):
order
=
self
.
order_queue
.
popleft
()
try
:
if
order
.
cancelled
:
order
.
failed
(
Cancelled
())
return
if
isinstance
(
order
,
SendMessage
):
self
.
backend
.
basic_publish
(
order
.
message
,
order
.
exchange
,
order
.
routing_key
)
elif
isinstance
(
order
,
SetQoS
):
...
...
This diff is collapsed.
Click to expand it.
coolamqp/orders.py
+
10
−
1
View file @
f970e359
...
...
@@ -15,6 +15,15 @@ class Order(object):
# exception instance on failed
self
.
lock
=
Lock
()
self
.
lock
.
acquire
()
self
.
cancelled
=
False
def
has_finished
(
self
):
"""
Return if this task has either completed or failed
"""
return
self
.
_result
is
not
None
def
cancel
(
self
):
"""
Cancel this order
"""
self
.
cancelled
=
True
def
completed
(
self
):
self
.
_result
=
True
...
...
@@ -25,7 +34,7 @@ class Order(object):
def
failed
(
self
,
e
):
"""
:param e: AMQPError instance
:param e: AMQPError instance
or Cancelled instance
"""
self
.
_result
=
e
self
.
lock
.
release
()
...
...
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