Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
98019e1c
Commit
98019e1c
authored
May 16, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #27034: Removed deprecated class asynchat.fifo.
parent
31e59aa7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
68 deletions
+10
-68
Doc/library/asynchat.rst
Doc/library/asynchat.rst
+8
-8
Lib/asynchat.py
Lib/asynchat.py
+0
-29
Lib/test/test_asynchat.py
Lib/test/test_asynchat.py
+0
-31
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/asynchat.rst
View file @
98019e1c
...
...
@@ -57,13 +57,13 @@ connection requests.
The asynchronous output buffer size (default ``4096``).
Unlike :class:`asyncore.dispatcher`, :class:`async_chat` allows you to
define a
first-in-first-out queue (fifo)
of *producers*. A producer need
define a
:abbr:`FIFO (first-in, first-out)` queue
of *producers*. A producer need
have only one method, :meth:`more`, which should return data to be
transmitted on the channel.
The producer indicates exhaustion (*i.e.* that it contains no more data) by
having its :meth:`more` method return the empty bytes object. At this point
the :class:`async_chat` object removes the producer from the
fifo
and starts
using the next producer, if any. When the producer
fifo
is empty the
the :class:`async_chat` object removes the producer from the
queue
and starts
using the next producer, if any. When the producer
queue
is empty the
:meth:`handle_write` method does nothing. You use the channel object's
:meth:`set_terminator` method to describe how to recognize the end of, or
an important breakpoint in, an incoming transmission from the remote
...
...
@@ -77,8 +77,8 @@ connection requests.
.. method:: async_chat.close_when_done()
Pushes a ``None`` on to the producer
fifo
. When this producer is popped off
the
fifo
it causes the channel to be closed.
Pushes a ``None`` on to the producer
queue
. When this producer is popped off
the
queue
it causes the channel to be closed.
.. method:: async_chat.collect_incoming_data(data)
...
...
@@ -91,7 +91,7 @@ connection requests.
.. method:: async_chat.discard_buffers()
In emergencies this method will discard any data held in the input and/or
output buffers and the producer
fifo
.
output buffers and the producer
queue
.
.. method:: async_chat.found_terminator()
...
...
@@ -109,7 +109,7 @@ connection requests.
.. method:: async_chat.push(data)
Pushes data on to the channel's
fifo
to ensure its transmission.
Pushes data on to the channel's
queue
to ensure its transmission.
This is all you need to do to have the channel write the data out to the
network, although it is possible to use your own producers in more complex
schemes to implement encryption and chunking, for example.
...
...
@@ -117,7 +117,7 @@ connection requests.
.. method:: async_chat.push_with_producer(producer)
Takes a producer object and adds it to the producer
fifo
associated with
Takes a producer object and adds it to the producer
queue
associated with
the channel. When all currently-pushed producers have been exhausted the
channel will consume this producer's data by calling its :meth:`more`
method and send the data to the remote endpoint.
...
...
Lib/asynchat.py
View file @
98019e1c
...
...
@@ -285,35 +285,6 @@ class simple_producer:
return
result
class
fifo
:
def
__init__
(
self
,
list
=
None
):
import
warnings
warnings
.
warn
(
'fifo class will be removed in Python 3.6'
,
DeprecationWarning
,
stacklevel
=
2
)
if
not
list
:
self
.
list
=
deque
()
else
:
self
.
list
=
deque
(
list
)
def
__len__
(
self
):
return
len
(
self
.
list
)
def
is_empty
(
self
):
return
not
self
.
list
def
first
(
self
):
return
self
.
list
[
0
]
def
push
(
self
,
data
):
self
.
list
.
append
(
data
)
def
pop
(
self
):
if
self
.
list
:
return
(
1
,
self
.
list
.
popleft
())
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.
...
...
Lib/test/test_asynchat.py
View file @
98019e1c
...
...
@@ -296,37 +296,6 @@ class TestHelperFunctions(unittest.TestCase):
self
.
assertEqual
(
asynchat
.
find_prefix_at_end
(
"qwertydkjf"
,
"
\
r
\
n
"
),
0
)
class
TestFifo
(
unittest
.
TestCase
):
def
test_basic
(
self
):
with
self
.
assertWarns
(
DeprecationWarning
)
as
cm
:
f
=
asynchat
.
fifo
()
self
.
assertEqual
(
str
(
cm
.
warning
),
"fifo class will be removed in Python 3.6"
)
f
.
push
(
7
)
f
.
push
(
b'a'
)
self
.
assertEqual
(
len
(
f
),
2
)
self
.
assertEqual
(
f
.
first
(),
7
)
self
.
assertEqual
(
f
.
pop
(),
(
1
,
7
))
self
.
assertEqual
(
len
(
f
),
1
)
self
.
assertEqual
(
f
.
first
(),
b'a'
)
self
.
assertEqual
(
f
.
is_empty
(),
False
)
self
.
assertEqual
(
f
.
pop
(),
(
1
,
b'a'
))
self
.
assertEqual
(
len
(
f
),
0
)
self
.
assertEqual
(
f
.
is_empty
(),
True
)
self
.
assertEqual
(
f
.
pop
(),
(
0
,
None
))
def
test_given_list
(
self
):
with
self
.
assertWarns
(
DeprecationWarning
)
as
cm
:
f
=
asynchat
.
fifo
([
b'x'
,
17
,
3
])
self
.
assertEqual
(
str
(
cm
.
warning
),
"fifo class will be removed in Python 3.6"
)
self
.
assertEqual
(
len
(
f
),
3
)
self
.
assertEqual
(
f
.
pop
(),
(
1
,
b'x'
))
self
.
assertEqual
(
f
.
pop
(),
(
1
,
17
))
self
.
assertEqual
(
f
.
pop
(),
(
1
,
3
))
self
.
assertEqual
(
f
.
pop
(),
(
0
,
None
))
class
TestNotConnected
(
unittest
.
TestCase
):
def
test_disallow_negative_terminator
(
self
):
# Issue #11259
...
...
Misc/NEWS
View file @
98019e1c
...
...
@@ -277,6 +277,8 @@ Core and Builtins
Library
-------
-
Issue
#
27034
:
Removed
deprecated
class
asynchat
.
fifo
.
-
Issue
#
26870
:
Added
readline
.
set_auto_history
(),
which
can
stop
entries
being
automatically
added
to
the
history
list
.
Based
on
patch
by
Tyler
Crompton
.
...
...
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