Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
shared-libs
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
Pi-Lab
shared-libs
Commits
5efbe741
Commit
5efbe741
authored
1 year ago
by
istmxrein
Browse files
Options
Downloads
Patches
Plain Diff
rework MetaListener
parent
3d0e56ee
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pilab/events/meta.py
+7
-10
7 additions, 10 deletions
pilab/events/meta.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
8 additions
and
11 deletions
pilab/events/meta.py
+
7
−
10
View file @
5efbe741
...
...
@@ -5,7 +5,7 @@ import time
import
traceback
from
enum
import
Enum
from
ipaddress
import
IPv4Address
from
typing
import
List
,
Optional
,
Callable
from
typing
import
List
,
Optional
,
Callable
,
Dict
import
pika
import
pika.exceptions
...
...
@@ -80,13 +80,12 @@ class Event(BaseModel):
payload
:
Cube
class
EventListener
(
threading
.
Thread
):
def
__init__
(
self
,
exchange
:
str
,
queue
:
str
,
callback
:
Callable
):
super
(
EventListener
,
self
).
__init__
()
self
.
exchange
:
str
=
exchange
class
MetaListener
(
threading
.
Thread
):
def
__init__
(
self
,
callback
:
Callable
,
queue
:
str
=
STREAM_NAME
,
offset
=
"
last
"
):
super
(
MetaListener
,
self
).
__init__
()
self
.
queue
:
str
=
queue
self
.
callback
:
Callable
=
callback
self
.
arguments
=
{
"
x-stream-offset
"
:
offset
}
self
.
channel
=
None
self
.
connection
=
None
...
...
@@ -105,10 +104,8 @@ class EventListener(threading.Thread):
try
:
self
.
connection
=
utils
.
get_blocking_connection
()
self
.
channel
=
self
.
connection
.
channel
()
self
.
channel
.
exchange_declare
(
exchange
=
self
.
exchange
,
exchange_type
=
'
fanout
'
)
self
.
channel
.
queue_declare
(
queue
=
self
.
queue
,
durable
=
True
,
exclusive
=
False
,
auto_delete
=
False
)
self
.
channel
.
queue_bind
(
exchange
=
self
.
exchange
,
queue
=
self
.
queue
)
self
.
channel
.
basic_consume
(
queue
=
self
.
queue
,
on_message_callback
=
self
.
default_callback
,
auto_ack
=
False
)
self
.
channel
.
queue_declare
(
queue
=
self
.
queue
,
durable
=
True
,
exclusive
=
False
,
auto_delete
=
False
,
arguments
=
{
"
x-queue-type
"
:
"
stream
"
})
self
.
channel
.
basic_consume
(
queue
=
self
.
queue
,
on_message_callback
=
self
.
default_callback
,
auto_ack
=
False
,
arguments
=
self
.
arguments
)
try
:
self
.
channel
.
start_consuming
()
except
SystemExit
:
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
5efbe741
...
...
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup
(
name
=
'
pilab
'
,
version
=
'
2.1.1
'
,
version
=
'
3.0.0
'
,
description
=
'
Shared-Libs for the pi-lab microservices
'
,
url
=
'
https://code.fbi.h-da.de/api/v4/projects/27896/packages/pypi/pilab
'
,
author
=
'
Max Reinheimer
'
,
...
...
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