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
3539ef3d
Kaydet (Commit)
3539ef3d
authored
Mar 22, 2012
tarafından
Giampaolo Rodola'
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge 79422b3684f1 in 3.3 branch (issue 10340)
üst
cc58031d
350c94b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
8 deletions
+25
-8
asyncore.py
Lib/asyncore.py
+9
-8
test_asyncore.py
Lib/test/test_asyncore.py
+16
-0
No files found.
Lib/asyncore.py
Dosyayı görüntüle @
3539ef3d
...
...
@@ -217,6 +217,7 @@ class dispatcher:
debug
=
False
connected
=
False
accepting
=
False
connecting
=
False
closing
=
False
addr
=
None
ignore_log_types
=
frozenset
([
'warning'
])
...
...
@@ -240,7 +241,7 @@ class dispatcher:
try
:
self
.
addr
=
sock
.
getpeername
()
except
socket
.
error
as
err
:
if
err
.
args
[
0
]
==
ENOTCONN
:
if
err
.
args
[
0
]
in
(
ENOTCONN
,
EINVAL
)
:
# To handle the case where we got an unconnected
# socket.
self
.
connected
=
False
...
...
@@ -334,6 +335,7 @@ class dispatcher:
def
connect
(
self
,
address
):
self
.
connected
=
False
self
.
connecting
=
True
err
=
self
.
socket
.
connect_ex
(
address
)
if
err
in
(
EINPROGRESS
,
EALREADY
,
EWOULDBLOCK
)
\
or
err
==
EINVAL
and
os
.
name
in
(
'nt'
,
'ce'
):
...
...
@@ -393,6 +395,7 @@ class dispatcher:
def
close
(
self
):
self
.
connected
=
False
self
.
accepting
=
False
self
.
connecting
=
False
self
.
del_channel
()
try
:
self
.
socket
.
close
()
...
...
@@ -431,7 +434,8 @@ class dispatcher:
# sockets that are connected
self
.
handle_accept
()
elif
not
self
.
connected
:
self
.
handle_connect_event
()
if
self
.
connecting
:
self
.
handle_connect_event
()
self
.
handle_read
()
else
:
self
.
handle_read
()
...
...
@@ -442,6 +446,7 @@ class dispatcher:
raise
socket
.
error
(
err
,
_strerror
(
err
))
self
.
handle_connect
()
self
.
connected
=
True
self
.
connecting
=
False
def
handle_write_event
(
self
):
if
self
.
accepting
:
...
...
@@ -450,12 +455,8 @@ class dispatcher:
return
if
not
self
.
connected
:
#check for errors
err
=
self
.
socket
.
getsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_ERROR
)
if
err
!=
0
:
raise
socket
.
error
(
err
,
_strerror
(
err
))
self
.
handle_connect_event
()
if
self
.
connecting
:
self
.
handle_connect_event
()
self
.
handle_write
()
def
handle_expt_event
(
self
):
...
...
Lib/test/test_asyncore.py
Dosyayı görüntüle @
3539ef3d
...
...
@@ -7,6 +7,7 @@ import sys
import
time
import
warnings
import
errno
import
struct
from
test
import
support
from
test.support
import
TESTFN
,
run_unittest
,
unlink
...
...
@@ -778,6 +779,21 @@ class BaseTestAPI(unittest.TestCase):
finally
:
sock
.
close
()
@unittest.skipUnless
(
threading
,
'Threading required for this test.'
)
@support.reap_threads
def
test_quick_connect
(
self
):
# see: http://bugs.python.org/issue10340
server
=
TCPServer
()
t
=
threading
.
Thread
(
target
=
lambda
:
asyncore
.
loop
(
timeout
=
0.1
,
count
=
500
))
t
.
start
()
for
x
in
range
(
20
):
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_LINGER
,
struct
.
pack
(
'ii'
,
1
,
0
))
s
.
connect
(
server
.
address
)
s
.
close
()
class
TestAPI_UseIPv4Sockets
(
BaseTestAPI
):
family
=
socket
.
AF_INET
...
...
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