Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
0b2e1c7a
Commit
0b2e1c7a
authored
3 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-703
: Use socket.recv to read from sockets, as Windows cannot use os.read for that
parent
e1d93b27
No related branches found
No related tags found
1 merge request
!282
Resolve L2SS-703 "Fix statisticswriter windows"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tangostationcontrol/tangostationcontrol/statistics_writer/receiver.py
+11
-1
11 additions, 1 deletion
...control/tangostationcontrol/statistics_writer/receiver.py
with
11 additions
and
1 deletion
tangostationcontrol/tangostationcontrol/statistics_writer/receiver.py
+
11
−
1
View file @
0b2e1c7a
...
@@ -27,6 +27,12 @@ class receiver:
...
@@ -27,6 +27,12 @@ class receiver:
# add payload to the header, and return the full packet
# add payload to the header, and return the full packet
return
header
+
payload
return
header
+
payload
def
_read
(
self
,
length
:
int
)
->
bytes
:
"""
Low-level read function to fetch at most
"
length
"
(>1) bytes. Returns
nothing if there is no data left.
"""
return
os
.
read
(
self
.
fd
,
length
)
def
read_data
(
self
,
data_length
:
int
)
->
bytes
:
def
read_data
(
self
,
data_length
:
int
)
->
bytes
:
"""
Read exactly data_length bytes from the TCP connection.
"""
"""
Read exactly data_length bytes from the TCP connection.
"""
...
@@ -35,7 +41,7 @@ class receiver:
...
@@ -35,7 +41,7 @@ class receiver:
# try to read the remainder.
# try to read the remainder.
# NOTE: recv() may return less data than requested, and returns 0
# NOTE: recv() may return less data than requested, and returns 0
# if there is nothing left to read (end of stream)
# if there is nothing left to read (end of stream)
more_data
=
os
.
read
(
self
.
fd
,
data_length
-
len
(
data
))
more_data
=
self
.
_read
(
data_length
-
len
(
data
))
if
not
more_data
:
if
not
more_data
:
# connection got dropped
# connection got dropped
raise
EOFError
(
"
End of stream
"
)
raise
EOFError
(
"
End of stream
"
)
...
@@ -54,6 +60,10 @@ class tcp_receiver(receiver):
...
@@ -54,6 +60,10 @@ class tcp_receiver(receiver):
super
().
__init__
(
fd
=
self
.
sock
.
fileno
())
super
().
__init__
(
fd
=
self
.
sock
.
fileno
())
def
_read
(
self
,
length
):
# On Windows, we cannot use os.read to read from sockets
return
self
.
sock
.
recv
(
length
)
def
reconnect
(
self
):
def
reconnect
(
self
):
self
.
fd
=
None
self
.
fd
=
None
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
...
...
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