Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Zope
Commits
6049e415
Commit
6049e415
authored
Dec 13, 2001
by
Brian Lloyd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged asyncore / asynchat fixes from 2.5 branch.
parent
78d70b09
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1292 additions
and
174 deletions
+1292
-174
ZServer/__init__.py
ZServer/__init__.py
+15
-2
ZServer/medusa/asynchat.py
ZServer/medusa/asynchat.py
+86
-85
ZServer/medusa/asyncore.py
ZServer/medusa/asyncore.py
+545
-0
lib/python/ZServer/__init__.py
lib/python/ZServer/__init__.py
+15
-2
lib/python/ZServer/medusa/asynchat.py
lib/python/ZServer/medusa/asynchat.py
+86
-85
lib/python/ZServer/medusa/asyncore.py
lib/python/ZServer/medusa/asyncore.py
+545
-0
No files found.
ZServer/__init__.py
View file @
6049e415
...
...
@@ -11,10 +11,23 @@
#
##############################################################################
import
sys
,
os
from
medusa.test
import
max_sockets
import
sys
,
os
# HACKERY to get around asyncore issues. This ought to go away! We're
# currently using the Python 2.2 asyncore bundled with Zope to override
# brokenness in the Python 2.1 version. We need to do some funny business
# to make this work, as a 2.2-ism crept into the asyncore code.
import
fcntl
,
FCNTL
if
not
hasattr
(
fcntl
,
'F_GETFL'
):
fcntl
.
F_GETFL
=
FCNTL
.
F_GETFL
fcntl
.
F_SETFL
=
FCNTL
.
F_SETFL
from
medusa
import
asyncore
sys
.
modules
[
'asyncore'
]
=
asyncore
from
medusa.test
import
max_sockets
CONNECTION_LIMIT
=
max_sockets
.
max_select_sockets
()
ZSERVER_VERSION
=
'1.1b1'
...
...
ZServer/medusa/asynchat.py
View file @
6049e415
# -*- Mode: Python; tab-width: 4 -*-
#
$Id: asynchat.py,v 1.17 2001/05/01 11:44:48 andreas Exp $
#
Id: asynchat.py,v 2.26 2000/09/07 22:29:26 rushing Exp
# Author: Sam Rushing <rushing@nightmare.com>
# ======================================================================
...
...
@@ -25,7 +25,7 @@
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# ======================================================================
"""A class supporting chat-style (command/response) protocols.
r
"""A class supporting chat-style (command/response) protocols.
This class adds support for 'chat' style protocols - where one side
sends a 'command', and the other sends a response (examples would be
...
...
@@ -48,7 +48,6 @@ you - by calling your self.found_terminator() method.
import
socket
import
asyncore
import
string
class
async_chat
(
asyncore
.
dispatcher
):
"""This is an abstract class. You must derive from this class, and add
...
...
@@ -120,7 +119,7 @@ class async_chat (asyncore.dispatcher):
# 3) end of buffer does not match any prefix:
# collect data
terminator_len
=
len
(
terminator
)
index
=
s
tring
.
find
(
self
.
ac_in_buffer
,
terminator
)
index
=
s
elf
.
ac_in_buffer
.
find
(
terminator
)
if
index
!=
-
1
:
# we found the terminator
if
index
>
0
:
...
...
@@ -166,7 +165,7 @@ class async_chat (asyncore.dispatcher):
# return len(self.ac_out_buffer) or len(self.producer_fifo) or (not self.connected)
# this is about twice as fast, though not as clear.
return
not
(
(
self
.
ac_out_buffer
is
''
)
and
(
self
.
ac_out_buffer
==
''
)
and
self
.
producer_fifo
.
is_empty
()
and
self
.
connected
)
...
...
@@ -270,23 +269,25 @@ class fifo:
else
:
return
(
0
,
None
)
# Given 'haystack', see if any prefix of 'needle' is at its end. This
# assumes an exact match has already been checked. Return the number of
# characters matched.
# for example:
# f_p_a_e ("qwerty\r", "\r\n") => 1
# f_p_a_e ("qwertydkjf", "\r\n") => 0
# f_p_a_e ("qwerty\r\n", "\r\n") => <undefined>
# this could maybe be made faster with a computed regex?
# [answer: no; circa Python-2.0, Jan 2001]
# new python: 28961/s
# old python: 18307/s
# re: 12820/s
# regex: 14035/s
# Given 'haystack', see if any prefix of 'needle' is at its end. This
# assumes an exact match has already been checked. Return the number of
# characters matched.
# for example:
# f_p_a_e ("qwerty\r", "\r\n") => 1
# f_p_a_e ("qwerty\r\n", "\r\n") => 2
# f_p_a_e ("qwertydkjf", "\r\n") => 0
# this could maybe be made faster with a computed regex?
# [answer: no; circa Python-2.0, Jan 2001]
# python: 18307/s
# re: 12820/s
# regex: 14035/s
def
find_prefix_at_end
(
haystack
,
needle
):
l
=
len
(
needle
)
-
1
while
l
and
not
haystack
.
endswith
(
needle
[:
l
]):
l
-=
1
return
l
nl
=
len
(
needle
)
result
=
0
for
i
in
range
(
1
,
nl
):
if
haystack
[
-
(
nl
-
i
):]
==
needle
[:(
nl
-
i
)]:
result
=
nl
-
i
break
return
result
ZServer/medusa/asyncore.py
0 → 100644
View file @
6049e415
This diff is collapsed.
Click to expand it.
lib/python/ZServer/__init__.py
View file @
6049e415
...
...
@@ -11,10 +11,23 @@
#
##############################################################################
import
sys
,
os
from
medusa.test
import
max_sockets
import
sys
,
os
# HACKERY to get around asyncore issues. This ought to go away! We're
# currently using the Python 2.2 asyncore bundled with Zope to override
# brokenness in the Python 2.1 version. We need to do some funny business
# to make this work, as a 2.2-ism crept into the asyncore code.
import
fcntl
,
FCNTL
if
not
hasattr
(
fcntl
,
'F_GETFL'
):
fcntl
.
F_GETFL
=
FCNTL
.
F_GETFL
fcntl
.
F_SETFL
=
FCNTL
.
F_SETFL
from
medusa
import
asyncore
sys
.
modules
[
'asyncore'
]
=
asyncore
from
medusa.test
import
max_sockets
CONNECTION_LIMIT
=
max_sockets
.
max_select_sockets
()
ZSERVER_VERSION
=
'1.1b1'
...
...
lib/python/ZServer/medusa/asynchat.py
View file @
6049e415
# -*- Mode: Python; tab-width: 4 -*-
#
$Id: asynchat.py,v 1.17 2001/05/01 11:44:48 andreas Exp $
#
Id: asynchat.py,v 2.26 2000/09/07 22:29:26 rushing Exp
# Author: Sam Rushing <rushing@nightmare.com>
# ======================================================================
...
...
@@ -25,7 +25,7 @@
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# ======================================================================
"""A class supporting chat-style (command/response) protocols.
r
"""A class supporting chat-style (command/response) protocols.
This class adds support for 'chat' style protocols - where one side
sends a 'command', and the other sends a response (examples would be
...
...
@@ -48,7 +48,6 @@ you - by calling your self.found_terminator() method.
import
socket
import
asyncore
import
string
class
async_chat
(
asyncore
.
dispatcher
):
"""This is an abstract class. You must derive from this class, and add
...
...
@@ -120,7 +119,7 @@ class async_chat (asyncore.dispatcher):
# 3) end of buffer does not match any prefix:
# collect data
terminator_len
=
len
(
terminator
)
index
=
s
tring
.
find
(
self
.
ac_in_buffer
,
terminator
)
index
=
s
elf
.
ac_in_buffer
.
find
(
terminator
)
if
index
!=
-
1
:
# we found the terminator
if
index
>
0
:
...
...
@@ -166,7 +165,7 @@ class async_chat (asyncore.dispatcher):
# return len(self.ac_out_buffer) or len(self.producer_fifo) or (not self.connected)
# this is about twice as fast, though not as clear.
return
not
(
(
self
.
ac_out_buffer
is
''
)
and
(
self
.
ac_out_buffer
==
''
)
and
self
.
producer_fifo
.
is_empty
()
and
self
.
connected
)
...
...
@@ -270,23 +269,25 @@ class fifo:
else
:
return
(
0
,
None
)
# Given 'haystack', see if any prefix of 'needle' is at its end. This
# assumes an exact match has already been checked. Return the number of
# characters matched.
# for example:
# f_p_a_e ("qwerty\r", "\r\n") => 1
# f_p_a_e ("qwertydkjf", "\r\n") => 0
# f_p_a_e ("qwerty\r\n", "\r\n") => <undefined>
# this could maybe be made faster with a computed regex?
# [answer: no; circa Python-2.0, Jan 2001]
# new python: 28961/s
# old python: 18307/s
# re: 12820/s
# regex: 14035/s
# Given 'haystack', see if any prefix of 'needle' is at its end. This
# assumes an exact match has already been checked. Return the number of
# characters matched.
# for example:
# f_p_a_e ("qwerty\r", "\r\n") => 1
# f_p_a_e ("qwerty\r\n", "\r\n") => 2
# f_p_a_e ("qwertydkjf", "\r\n") => 0
# this could maybe be made faster with a computed regex?
# [answer: no; circa Python-2.0, Jan 2001]
# python: 18307/s
# re: 12820/s
# regex: 14035/s
def
find_prefix_at_end
(
haystack
,
needle
):
l
=
len
(
needle
)
-
1
while
l
and
not
haystack
.
endswith
(
needle
[:
l
]):
l
-=
1
return
l
nl
=
len
(
needle
)
result
=
0
for
i
in
range
(
1
,
nl
):
if
haystack
[
-
(
nl
-
i
):]
==
needle
[:(
nl
-
i
)]:
result
=
nl
-
i
break
return
result
lib/python/ZServer/medusa/asyncore.py
0 → 100644
View file @
6049e415
This diff is collapsed.
Click to expand it.
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