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
15faa9c8
Kaydet (Commit)
15faa9c8
authored
Ara 03, 2013
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
asyncio doc: simplify ping example, remove the useless timeout
üst
153b894f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
7 deletions
+3
-7
asyncio-protocol.rst
Doc/library/asyncio-protocol.rst
+3
-7
No files found.
Doc/library/asyncio-protocol.rst
Dosyayı görüntüle @
15faa9c8
...
@@ -589,25 +589,21 @@ TCP echo server example::
...
@@ -589,25 +589,21 @@ TCP echo server example::
import asyncio
import asyncio
class EchoServer(asyncio.Protocol):
class EchoServer(asyncio.Protocol):
def timeout(self):
print('connection timeout, closing.')
self.transport.close()
def connection_made(self, transport):
def connection_made(self, transport):
print('connection made')
print('connection made')
self.transport = transport
self.transport = transport
# close the client connection after 2 seconds
asyncio.get_event_loop().call_later(2.0, self.timeout)
def data_received(self, data):
def data_received(self, data):
print('data received:', data.decode())
print('data received:', data.decode())
self.transport.write(data)
self.transport.write(data)
# close the socket
self.transport.close()
def connection_lost(self, exc):
def connection_lost(self, exc):
print('connection lost')
print('connection lost')
loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop()
f = loop.create_server(EchoServer, '127.0.0.1', 8888)
f = loop.create_server(EchoServer, '127.0.0.1', 8888)
s = loop.run_until_complete(f)
s = loop.run_until_complete(f)
...
...
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