Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
6486fc5f
Commit
6486fc5f
authored
Mar 31, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
counting statistics for RemoteDataZMQ
parent
6f086458
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
tensorpack/dataflow/remote.py
tensorpack/dataflow/remote.py
+15
-1
No files found.
tensorpack/dataflow/remote.py
View file @
6486fc5f
...
...
@@ -52,7 +52,12 @@ def send_dataflow_zmq(df, addr, hwm=50, print_interval=100):
class
RemoteDataZMQ
(
DataFlow
):
""" Produce data from ZMQ PULL socket(s). """
"""
Produce data from ZMQ PULL socket(s).
Attributes:
cnt1, cnt2 (int): number of data points received from addr1 and addr2
"""
def
__init__
(
self
,
addr1
,
addr2
=
None
):
"""
Args:
...
...
@@ -64,6 +69,10 @@ class RemoteDataZMQ(DataFlow):
self
.
_addr1
=
addr1
self
.
_addr2
=
addr2
def
reset_state
(
self
):
self
.
cnt1
=
0
self
.
cnt2
=
0
def
get_data
(
self
):
try
:
ctx
=
zmq
.
Context
()
...
...
@@ -75,6 +84,7 @@ class RemoteDataZMQ(DataFlow):
while
True
:
dp
=
loads
(
socket
.
recv
(
copy
=
False
)
.
bytes
)
yield
dp
self
.
cnt1
+=
1
else
:
socket1
=
ctx
.
socket
(
zmq
.
PULL
)
socket1
.
set_hwm
(
50
)
...
...
@@ -93,6 +103,10 @@ class RemoteDataZMQ(DataFlow):
for
sock
,
evt
in
evts
:
dp
=
loads
(
sock
.
recv
(
copy
=
False
)
.
bytes
)
yield
dp
if
sock
==
socket1
:
self
.
cnt1
+=
1
else
:
self
.
cnt2
+=
1
finally
:
ctx
.
destroy
(
linger
=
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment