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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
e6930d9d
Commit
e6930d9d
authored
Aug 29, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Break long messages into pieces in message_output().
As suggested by Toby Dickenson.
parent
aec6c454
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
18 deletions
+24
-18
src/ZEO/smac.py
src/ZEO/smac.py
+12
-9
src/ZEO/zrpc/smac.py
src/ZEO/zrpc/smac.py
+12
-9
No files found.
src/ZEO/smac.py
View file @
e6930d9d
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Sized message async connections
$Id: smac.py,v 1.2
1 2002/08/29 16:31:17 gvanrossum
Exp $
$Id: smac.py,v 1.2
2 2002/08/29 22:39:51 jeremy
Exp $
"""
import
asyncore
,
struct
...
...
@@ -41,6 +41,10 @@ tmp_dict = {errno.EAGAIN: 0,
expected_socket_write_errors
=
tuple
(
tmp_dict
.
keys
())
del
tmp_dict
# We chose 60000 as the socket limit by looking at the largest strings
# that we could pass to send() without blocking.
SEND_SIZE
=
60000
class
SizedMessageAsyncConnection
(
asyncore
.
dispatcher
):
__super_init
=
asyncore
.
dispatcher
.
__init__
__super_close
=
asyncore
.
dispatcher
.
close
...
...
@@ -145,14 +149,10 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
# delayed acks. If we send a very large string, only a
# portion of it will actually be delivered at a time.
# We chose 60000 as the socket limit by looking at the
# largest strings that we could pass to send() without
# blocking.
l
=
0
for
i
in
range
(
len
(
output
)):
l
+=
len
(
output
[
i
])
if
l
>
60000
:
if
l
>
SEND_SIZE
:
break
i
+=
1
...
...
@@ -167,8 +167,6 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
break
# we couldn't write anything
raise
if
n
<
len
(
v
):
# XXX It's unfortunate that we end up making many
# slices of a large string.
output
.
insert
(
0
,
v
[
n
:])
break
# we can't write any more
...
...
@@ -191,7 +189,12 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
)
# do two separate appends to avoid copying the message string
self
.
__output
.
append
(
struct
.
pack
(
">i"
,
len
(
message
)))
self
.
__output
.
append
(
message
)
if
len
(
message
)
<=
SEND_SIZE
:
self
.
__output
.
append
(
message
)
else
:
for
i
in
range
(
0
,
len
(
message
),
SEND_SIZE
):
self
.
__output
.
append
(
message
[
i
:
i
+
SEND_SIZE
])
def
close
(
self
):
if
self
.
__closed
is
None
:
...
...
src/ZEO/zrpc/smac.py
View file @
e6930d9d
...
...
@@ -13,7 +13,7 @@
##############################################################################
"""Sized message async connections
$Id: smac.py,v 1.2
1 2002/08/29 16:31:17 gvanrossum
Exp $
$Id: smac.py,v 1.2
2 2002/08/29 22:39:51 jeremy
Exp $
"""
import
asyncore
,
struct
...
...
@@ -41,6 +41,10 @@ tmp_dict = {errno.EAGAIN: 0,
expected_socket_write_errors
=
tuple
(
tmp_dict
.
keys
())
del
tmp_dict
# We chose 60000 as the socket limit by looking at the largest strings
# that we could pass to send() without blocking.
SEND_SIZE
=
60000
class
SizedMessageAsyncConnection
(
asyncore
.
dispatcher
):
__super_init
=
asyncore
.
dispatcher
.
__init__
__super_close
=
asyncore
.
dispatcher
.
close
...
...
@@ -145,14 +149,10 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
# delayed acks. If we send a very large string, only a
# portion of it will actually be delivered at a time.
# We chose 60000 as the socket limit by looking at the
# largest strings that we could pass to send() without
# blocking.
l
=
0
for
i
in
range
(
len
(
output
)):
l
+=
len
(
output
[
i
])
if
l
>
60000
:
if
l
>
SEND_SIZE
:
break
i
+=
1
...
...
@@ -167,8 +167,6 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
break
# we couldn't write anything
raise
if
n
<
len
(
v
):
# XXX It's unfortunate that we end up making many
# slices of a large string.
output
.
insert
(
0
,
v
[
n
:])
break
# we can't write any more
...
...
@@ -191,7 +189,12 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
)
# do two separate appends to avoid copying the message string
self
.
__output
.
append
(
struct
.
pack
(
">i"
,
len
(
message
)))
self
.
__output
.
append
(
message
)
if
len
(
message
)
<=
SEND_SIZE
:
self
.
__output
.
append
(
message
)
else
:
for
i
in
range
(
0
,
len
(
message
),
SEND_SIZE
):
self
.
__output
.
append
(
message
[
i
:
i
+
SEND_SIZE
])
def
close
(
self
):
if
self
.
__closed
is
None
:
...
...
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