Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
force-bdss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adham Hashibon
force-bdss
Commits
f57f914f
Commit
f57f914f
authored
7 years ago
by
Stefano Borini
Browse files
Options
Downloads
Patches
Plain Diff
Made small protocol
parent
15919e38
No related branches found
No related tags found
1 merge request
!79
Deliver notification info
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
force_bdss/core_plugins/dummy/ui_notification/ui_notification.py
+18
-3
18 additions, 3 deletions
...dss/core_plugins/dummy/ui_notification/ui_notification.py
utils/zmq_client.py
+5
-9
5 additions, 9 deletions
utils/zmq_client.py
with
23 additions
and
12 deletions
force_bdss/core_plugins/dummy/ui_notification/ui_notification.py
+
18
−
3
View file @
f57f914f
import
errno
import
logging
from
traits.api
import
Any
,
List
from
traits.api
import
Any
,
List
from
force_bdss.api
import
BaseNotificationListener
from
force_bdss.api
import
BaseNotificationListener
...
@@ -5,17 +7,30 @@ import zmq
...
@@ -5,17 +7,30 @@ import zmq
class
UINotification
(
BaseNotificationListener
):
class
UINotification
(
BaseNotificationListener
):
#: The ZMQ context.
_context
=
Any
()
_context
=
Any
()
#: The pubsub socket.
_pub_socket
=
Any
()
_pub_socket
=
Any
()
#: The synchronization socket to recover already sent information at a
#: later stage
_rep_socket
=
Any
()
_rep_socket
=
Any
()
#: The cache of messages as they are sent out.
_msg_cache
=
List
()
_msg_cache
=
List
()
def
deliver
(
self
,
model
,
message
):
def
deliver
(
self
,
model
,
message
):
try
:
try
:
data
=
self
.
_rep_socket
.
recv
(
flags
=
zmq
.
NOBLOCK
)
data
=
self
.
_rep_socket
.
recv
(
flags
=
zmq
.
NOBLOCK
)
except
zmq
.
ZMQError
:
except
zmq
.
ZMQError
as
e
:
pass
if
e
.
errno
==
errno
.
EAGAIN
:
else
:
data
=
None
else
:
logging
.
error
(
"
Error while receiving data from
"
"
reply socket: {}
"
.
format
(
str
(
e
)))
if
data
and
data
[
0
:
4
]
==
"
SYNC
"
.
encode
(
"
utf-8
"
):
self
.
_rep_socket
.
send_multipart
(
self
.
_msg_cache
)
self
.
_rep_socket
.
send_multipart
(
self
.
_msg_cache
)
msg
=
"
ACTION {}
"
.
format
(
message
).
encode
(
"
utf-8
"
)
msg
=
"
ACTION {}
"
.
format
(
message
).
encode
(
"
utf-8
"
)
...
...
This diff is collapsed.
Click to expand it.
utils/zmq_client.py
+
5
−
9
View file @
f57f914f
...
@@ -9,16 +9,12 @@ socket.connect("tcp://localhost:12345")
...
@@ -9,16 +9,12 @@ socket.connect("tcp://localhost:12345")
socket
.
setsockopt
(
zmq
.
SUBSCRIBE
,
""
.
encode
(
"
utf-8
"
))
socket
.
setsockopt
(
zmq
.
SUBSCRIBE
,
""
.
encode
(
"
utf-8
"
))
send_socket
=
context
.
socket
(
zmq
.
REQ
)
send_socket
=
context
.
socket
(
zmq
.
REQ
)
send_socket
.
connect
(
"
tcp://localhost:12346
"
)
send_socket
.
connect
(
"
tcp://localhost:12346
"
)
send_socket
.
send
(
"
hello
"
.
encode
(
"
utf-8
"
))
while
True
:
try
:
data
=
send_socket
.
recv_multipart
(
flags
=
zmq
.
NOBLOCK
)
except
zmq
.
ZMQError
:
pass
else
:
print
(
"
RECOVERING CACHE
"
,
data
)
break
send_socket
.
send
(
"
SYNC
"
.
encode
(
"
utf-8
"
))
data
=
send_socket
.
recv_multipart
()
for
d
in
data
:
topic
,
messagedata
=
d
.
split
()
print
(
"
SYNCED
"
,
topic
,
messagedata
)
while
True
:
while
True
:
string
=
socket
.
recv
()
string
=
socket
.
recv
()
...
...
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