Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
f184a1d9
Commit
f184a1d9
authored
Aug 15, 2022
by
Kirill Smelkov
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X trace IO in between client and server
parent
fc0729b3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
src/ZEO/asyncio/base.py
src/ZEO/asyncio/base.py
+23
-0
No files found.
src/ZEO/asyncio/base.py
View file @
f184a1d9
...
...
@@ -31,10 +31,14 @@ The ZEO protocol sits on top of a sized message protocol.
The ZEO protocol has client and server variants.
"""
from
__future__
import
print_function
import
logging
import
socket
from
struct
import
unpack
import
sys
import
tempfile
from
.compat
import
asyncio
...
...
@@ -43,6 +47,8 @@ logger = logging.getLogger(__name__)
INET_FAMILIES
=
socket
.
AF_INET
,
socket
.
AF_INET6
traceio
=
not
(
'runzeo'
in
sys
.
argv
[
0
])
# trace on client side
print
(
'%s traceio=%s'
%
(
sys
.
argv
[
0
],
traceio
))
class
Protocol
(
asyncio
.
Protocol
):
"""asyncio low-level ZEO base interface
...
...
@@ -66,6 +72,18 @@ class Protocol(asyncio.Protocol):
# Handle the first message, the protocol handshake, differently
self
.
message_received
=
self
.
first_message_received
self
.
tracefile
=
tempfile
.
NamedTemporaryFile
(
bufsize
=
1
*
1024
*
1024
,
prefix
=
'ZEO'
,
suffix
=
'.iotrace'
,
delete
=
False
,
dir
=
'/tmp'
)
def
_traceio
(
self
,
txrx
,
message
):
if
traceio
:
x
=
message
decode
=
getattr
(
self
,
'decode'
,
None
)
if
decode
is
not
None
:
try
:
x
=
decode
(
x
)
except
:
pass
print
(
'%s %r'
%
(
txrx
,
x
),
file
=
self
.
tracefile
)
def
__repr__
(
self
):
return
self
.
name
...
...
@@ -98,6 +116,7 @@ class Protocol(asyncio.Protocol):
if
paused
:
append
(
message
)
else
:
self
.
_traceio
(
'tx'
,
message
)
writelines
((
pack
(
">I"
,
len
(
message
)),
message
))
self
.
write_message
=
write_message
...
...
@@ -111,6 +130,7 @@ class Protocol(asyncio.Protocol):
append
(
data
)
return
for
message
in
data
:
self
.
_traceio
(
'tx'
,
message
)
writelines
((
pack
(
">I"
,
len
(
message
)),
message
))
if
paused
:
append
(
data
)
...
...
@@ -159,6 +179,7 @@ class Protocol(asyncio.Protocol):
else
:
self
.
want
=
4
self
.
getting_size
=
True
self
.
_traceio
(
'rx'
,
collected
)
self
.
message_received
(
collected
)
except
Exception
:
logger
.
exception
(
"data_received %s %s %s"
,
...
...
@@ -189,10 +210,12 @@ class Protocol(asyncio.Protocol):
while
output
and
not
paused
:
message
=
output
.
pop
(
0
)
if
isinstance
(
message
,
bytes
):
self
.
_traceio
(
'tx'
,
message
)
writelines
((
pack
(
">I"
,
len
(
message
)),
message
))
else
:
data
=
message
for
message
in
data
:
self
.
_traceio
(
'tx'
,
message
)
writelines
((
pack
(
">I"
,
len
(
message
)),
message
))
if
paused
:
# paused again. Put iter back.
output
.
insert
(
0
,
data
)
...
...
Kirill Smelkov
@kirr
mentioned in commit
72320df7
·
Oct 11, 2022
mentioned in commit
72320df7
mentioned in commit 72320df7ee729f860d9a1656e904d2691335e671
Toggle commit list
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