Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
103a6d6c
Kaydet (Commit)
103a6d6c
authored
Şub 25, 2011
tarafından
Giampaolo Rodolà
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 11177: asyncore's create_socket() arguments can now be omitted.
üst
0bd4deba
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
14 deletions
+18
-14
asyncore.rst
Doc/library/asyncore.rst
+5
-3
asyncore.py
Lib/asyncore.py
+1
-1
test_asyncore.py
Lib/test/test_asyncore.py
+10
-10
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/asyncore.rst
Dosyayı görüntüle @
103a6d6c
...
...
@@ -184,12 +184,14 @@ any that have been added to the map during asynchronous service) is closed.
Most of these are nearly identical to their socket partners.
.. method:: create_socket(family
, type
)
.. method:: create_socket(family
=socket.AF_INET, type=socket.SOCK_STREAM
)
This is identical to the creation of a normal socket, and will use the
same options for creation. Refer to the :mod:`socket` documentation for
information on creating sockets.
.. versionchanged:: 3.3 family and type arguments can be omitted.
.. method:: connect(address)
...
...
@@ -280,7 +282,7 @@ implement its socket handling::
def __init__(self, host, path):
asyncore.dispatcher.__init__(self)
self.create_socket(
socket.AF_INET, socket.SOCK_STREAM
)
self.create_socket()
self.connect( (host, 80) )
self.buffer = bytes('GET %s HTTP/1.0\r\n\r\n' % path, 'ascii')
...
...
@@ -326,7 +328,7 @@ connections and dispatches the incoming connections to a handler::
def __init__(self, host, port):
asyncore.dispatcher.__init__(self)
self.create_socket(
socket.AF_INET, socket.SOCK_STREAM
)
self.create_socket()
self.set_reuse_addr()
self.bind((host, port))
self.listen(5)
...
...
Lib/asyncore.py
Dosyayı görüntüle @
103a6d6c
...
...
@@ -287,7 +287,7 @@ class dispatcher:
del
map
[
fd
]
self
.
_fileno
=
None
def
create_socket
(
self
,
family
,
type
):
def
create_socket
(
self
,
family
=
socket
.
AF_INET
,
type
=
socket
.
SOCK_STREAM
):
self
.
family_and_type
=
family
,
type
sock
=
socket
.
socket
(
family
,
type
)
sock
.
setblocking
(
0
)
...
...
Lib/test/test_asyncore.py
Dosyayı görüntüle @
103a6d6c
...
...
@@ -352,7 +352,7 @@ class DispatcherWithSendTests(unittest.TestCase):
@support.reap_threads
def
test_send
(
self
):
evt
=
threading
.
Event
()
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
=
socket
.
socket
()
sock
.
settimeout
(
3
)
port
=
support
.
bind_port
(
sock
)
...
...
@@ -367,7 +367,7 @@ class DispatcherWithSendTests(unittest.TestCase):
data
=
b
"Suppose there isn't a 16-ton weight?"
d
=
dispatcherwithsend_noread
()
d
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
d
.
create_socket
()
d
.
connect
((
HOST
,
port
))
# give time for socket to connect
...
...
@@ -474,7 +474,7 @@ class TCPServer(asyncore.dispatcher):
def
__init__
(
self
,
handler
=
BaseTestHandler
,
host
=
HOST
,
port
=
0
):
asyncore
.
dispatcher
.
__init__
(
self
)
self
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
create_socket
()
self
.
set_reuse_addr
()
self
.
bind
((
host
,
port
))
self
.
listen
(
5
)
...
...
@@ -495,7 +495,7 @@ class BaseClient(BaseTestHandler):
def
__init__
(
self
,
address
):
BaseTestHandler
.
__init__
(
self
)
self
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
create_socket
()
self
.
connect
(
address
)
def
handle_connect
(
self
):
...
...
@@ -536,7 +536,7 @@ class BaseTestAPI(unittest.TestCase):
def
__init__
(
self
):
BaseTestHandler
.
__init__
(
self
)
self
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
create_socket
()
self
.
bind
((
HOST
,
0
))
self
.
listen
(
5
)
self
.
address
=
self
.
socket
.
getsockname
()[:
2
]
...
...
@@ -555,7 +555,7 @@ class BaseTestAPI(unittest.TestCase):
def
__init__
(
self
):
BaseTestHandler
.
__init__
(
self
)
self
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
create_socket
()
self
.
bind
((
HOST
,
0
))
self
.
listen
(
5
)
self
.
address
=
self
.
socket
.
getsockname
()[:
2
]
...
...
@@ -693,20 +693,20 @@ class BaseTestAPI(unittest.TestCase):
def
test_create_socket
(
self
):
s
=
asyncore
.
dispatcher
()
s
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
create_socket
()
self
.
assertEqual
(
s
.
socket
.
family
,
socket
.
AF_INET
)
SOCK_NONBLOCK
=
getattr
(
socket
,
'SOCK_NONBLOCK'
,
0
)
self
.
assertEqual
(
s
.
socket
.
type
,
socket
.
SOCK_STREAM
|
SOCK_NONBLOCK
)
def
test_bind
(
self
):
s1
=
asyncore
.
dispatcher
()
s1
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s1
.
create_socket
()
s1
.
bind
((
HOST
,
0
))
s1
.
listen
(
5
)
port
=
s1
.
socket
.
getsockname
()[
1
]
s2
=
asyncore
.
dispatcher
()
s2
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s2
.
create_socket
()
# EADDRINUSE indicates the socket was correctly bound
self
.
assertRaises
(
socket
.
error
,
s2
.
bind
,
(
HOST
,
port
))
...
...
@@ -723,7 +723,7 @@ class BaseTestAPI(unittest.TestCase):
self
.
assertFalse
(
s
.
socket
.
getsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
))
s
.
socket
.
close
()
s
.
create_socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
create_socket
()
s
.
set_reuse_addr
()
self
.
assertTrue
(
s
.
socket
.
getsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
))
...
...
Misc/NEWS
Dosyayı görüntüle @
103a6d6c
...
...
@@ -35,6 +35,8 @@ Core and Builtins
Library
-------
- Issue 11177: asyncore'
s
create_socket
()
arguments
can
now
be
omitted
.
-
Issue
#
6064
:
Add
a
``
daemon
``
keyword
argument
to
the
threading
.
Thread
and
multiprocessing
.
Process
constructors
in
order
to
override
the
default
behaviour
of
inheriting
the
daemonic
property
from
the
current
...
...
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